#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,f[21][1<<21|1];char str[1<<21|1];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;++i){
		scanf("%s",str);
		for(int j=0;j<1<<i;++j)
			f[0][j<<n-i+1|1<<n-i]=str[j]-'0';
	}
	for(int i=0;i<n;++i)
		for(int j=0;j<1<<n+1;++j)
			if(f[i][j]){
				int a=j&(1<<i)-1,b=j^a,c=__builtin_ctz(b);
				b^=1<<c;
				if(b){
					f[i+1][b|1<<i|a]+=f[i][j];
				}
				if(b+(1<<c+1)<(1<<n+1)){
					int nc=__builtin_ctz(~b>>c+1<<c+1);
					f[i+1][b>>nc<<nc|1<<nc|a]+=f[i][j];
				}
			}
	for(int i=n;~i;--i)
		for(int j=0;j<1<<i;++j){
			int res=0;
			for(int k=0;k<1<<n+1-i;++k)
				res+=f[i][k<<i|j];
			if(res>=m){
				for(int k=i-1;~k;--k)putchar('0'+(j>>k&1));
				return puts(""),0;
			}
		}
	return 0;
}
