#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=24,S=1200120;
int n,K,L,ans,f[N][S],g[N][S];
char s[S];
int main(){
	scanf("%d%d",&n,&K);
	FOR(i,0,n){
		scanf("%s",s);
		FOR(j,0,(1<<i)-1) f[i][j]=s[j]=='1'; 
	}
	FOR(i,1,n)FOR(j,0,(1<<i)-1){
		int t=j>>i-1&1,r=i-1;
		for(;r && (j>>r-1&1)==t;r--);g[i][j]=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) f[i+t][(k>>j<<t)|(k&(1<<t)-1)]+=f[i+j][k];
		}
		ROF(j,(1<<i)-1,0)if(f[i][j]>=K) L=i,ans=j;
	}
	for(L--;~L;L--) cout<<(ans>>L&1);cout<<"\n";
}/*
5 100
0
01
1011
11010111
0001110111011110
01100100100011110101111111011010
*/