#include<bits/stdc++.h>
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
const int N=1048580,M=21;
int n,m,len,ans;
int f[M][N],g[M][N];
char s[N];
int main(){
	scanf("%d%d",&n,&m);
	For(i,0,n){
		scanf("%s",s);
		For(j,0,(1<<i)-1)
			f[i][j]=s[j]-'0';
	}
	For(i,1,n) For(j,0,(1<<i)-1){
		int b=(j>>(i-1))&1,r=0;
		for (;r<i&&((j>>(i-r-1))&1)==b;r++);
		g[i][j]=(r==i?-1:r);
	}
	For(i,0,n){
		For(j,1,n-i) For(k,0,(1<<(i+j))-1){
			f[i][k>>j]+=f[i+j][k];
			int t=g[j][k&((1<<j)-1)];
			if (t==-1) continue;
			f[i+j-t][((k>>j)<<(j-t))|(k&((1<<(j-t))-1))]+=f[i+j][k];
		}
		for (int j=(1<<i)-1;j>=0;j--)
			if (f[i][j]>=m){
				len=i; ans=j;
			}
	}
	for (int i=len-1;i>=0;i--)
		printf("%d",(ans>>i)&1);
}