#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2097153, M = N * 19;
char S[N];
int n,k,Len[N],cnt,dp[N][21],deg[N][21],sta1[M],top;
short sta2[M];
#define bh(s,l) ((s)+(1<<(l)))
inline void getnxt(int len, int s, int l, int &x, int &y, bool v) {
	per(pos,len,1) if (((s>>(pos-1))&1)==v) {
		y=pos-1;
		x=bh(((((s>>len)<<1)+v)<<(pos-1))|(s&((1<<(pos-1))-1)),l-len+pos); 
		return;
	}
	x=0;y=0;
}
int main() { //freopen("1.in","r",stdin);
	read(n);read(k);
	rep(i,0,n){
		scanf("%s",S+1);
		rep(j,1,1<<i) Len[++cnt]=i,dp[cnt][i]=(S[j]=='1');
	}
	rep(now,1,cnt) rep(len,1,Len[now]) {
		int l=Len[now],s=now-(1<<l);
		int x=bh(s>>len,l-len),y=0; ++deg[x][y];
	//	printf("nxt[%d,%d]=%d,%d\n",now,len,x,y);
		getnxt(len,s,l,x,y,0); ++deg[x][y];
	//	printf("nxt[%d,%d]=%d,%d\n",now,len,x,y);
		getnxt(len,s,l,x,y,1); ++deg[x][y];
	//	printf("nxt[%d,%d]=%d,%d\n",now,len,x,y);
	}
	rep(now,1,cnt) rep(len,1,Len[now]) if (!deg[now][len]) sta1[++top]=now,sta2[top]=len;
	while (top) {
		int now=sta1[top],len=sta2[top--]; if (!(now>=1&&len>=1)) continue; //len>=1
		int l=Len[now],s=now-(1<<l),val=dp[now][len];
		int x=bh(s>>len,l-len),y=0; if (!(--deg[x][y])) sta1[++top]=x,sta2[top]=y; dp[x][y]+=val;
		getnxt(len,s,l,x,y,0); if (!(--deg[x][y])) sta1[++top]=x,sta2[top]=y; dp[x][y]+=val;
		getnxt(len,s,l,x,y,1); if (!(--deg[x][y])) sta1[++top]=x,sta2[top]=y; dp[x][y]+=val;
	}
	int ans=1; rep(i,2,cnt) if (dp[i][0]>=k&&(Len[i]>Len[ans])) ans=i;
//	rep(i,1,cnt) printf("%d : %d\n",i,dp[i][0]);
//	printf("ans = %d\n",ans);
	per(i,Len[ans],1) printf("%d",((ans-(1<<Len[ans]))>>(i-1))&1);
	return 0;
}
