#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,K;
int f[2100000][22];
char s[2100000];
int main() {
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;i++){
		scanf("%s",s);
		int lim=(1<<i);
		for (int j=0;j<lim;j++) f[lim|j][i]=(s[j]-'0');
	}
	for (int i=n;i>=0;i--)
		for (int s=0;s<(1<<i);s++)
			for (int j=i;j>=0;j--){
				int cur=f[(1<<i)|s][j];
				if (cur){
					int s1=s>>j;
					int s2=s&((1<<j)-1);
					if (j) f[(1<<(i-j))|s1][0]+=cur;
					if (s2){
						int p=j-1;
						while (!((s2>>p)&1)) p--;
						f[(1<<(i-(j-1-p)))|(s1<<(p+1))|(s2&((1<<p)-1))|(1<<p)][p]+=cur;
					}
					if (((1<<j)-1)&(~s2)){
						int p=j-1;
						while ((s2>>p)&1) p--;
						f[(1<<(i-(j-1-p)))|(s1<<(p+1))|(s2&((1<<p)-1))][p]+=cur;
					}
				}
			}
	for (int i=n;i>=0;i--)
		for (int j=0;j<(1<<i);j++)
			if (f[(1<<i)|j][0]>=K){
				for(int k=i-1;k>=0;k--) printf("%d",(j>>k)&1);
				return 0;
			}
	return 0;
}
