#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

int n,k;

namespace BIN{
    int a0[1][1<<0];
    int a1[2][1<<1];
    int a2[3][1<<2];
    int a3[4][1<<3];
    int a4[5][1<<4];
    int a5[6][1<<5];
    int a6[7][1<<6];
    int a7[8][1<<7];
    int a8[9][1<<8];
    int a9[10][1<<9];
    int a10[11][1<<10];
    int a11[12][1<<11];
    int a12[13][1<<12];
    int a13[14][1<<13];
    int a14[15][1<<14];
    int a15[16][1<<15];
    int a16[17][1<<16];
    int a17[18][1<<17];
    int a18[19][1<<18];
    int a19[20][1<<19];
    int a20[21][1<<20];

    int A[22][1<<21];
}
int & f(int len,int status,int split){
    assert(split<=len);
    assert(status < (1<<len));
    return BIN::A[split][status | (1<<len)];
    if(len==0)return BIN::a0[split][status];
    if(len==1)return BIN::a1[split][status];
    if(len==2)return BIN::a2[split][status];
    if(len==3)return BIN::a3[split][status];
    if(len==4)return BIN::a4[split][status];
    if(len==5)return BIN::a5[split][status];
    if(len==6)return BIN::a6[split][status];
    if(len==7)return BIN::a7[split][status];
    if(len==8)return BIN::a8[split][status];
    if(len==9)return BIN::a9[split][status];
    if(len==10)return BIN::a10[split][status];
    if(len==11)return BIN::a11[split][status];
    if(len==12)return BIN::a12[split][status];
    if(len==13)return BIN::a13[split][status];
    if(len==14)return BIN::a14[split][status];
    if(len==15)return BIN::a15[split][status];
    if(len==16)return BIN::a16[split][status];
    if(len==17)return BIN::a17[split][status];
    if(len==18)return BIN::a18[split][status];
    if(len==19)return BIN::a19[split][status];
    if(len==20)return BIN::a20[split][status];
    puts("ERROR!");
    exit(1);
}

char P[100];
char * print(int len,int status){
    //printf("print(%d,%d)\n",len,status);
    int l=0;
    ROF(i,len-1,0)P[l++]=(status>>i&1)+'0';
    P[l]=0;
    return P;
}
void build(){
    ROF(i,n,1){//len
        int lim=1<<i;
        FOR(j,0,lim-1){
            //int last0=-1,last1=-1;
            int last0[25],last1[25];
            last0[0]=last1[0]=-1;
            FOR(k,0,i){
                last0[k+1]=last0[k];
                last1[k+1]=last1[k];
                if(j>>k&1)last1[k+1]=k;
                else last0[k+1]=k;
            }
            ROF(k,i,0){//中括号开始前的那个字符，从低位往高位枚举，实际上是倒着枚举
                if(!f(i,j,k))continue;
                //printf("\033[33mf(%d,%s,%d)=%d\033[0m\n",i,print(i,j),k,f(i,j,k));
                //printf("last0[%d]=%d\n",k,last0[k]);
                //printf("last1[%d]=%d\n",k,last1[k]);

                if(k>0){//then link to s[]
                    f(i-k,j>>k,0)+=f(i,j,k);
                    //printf("\033[32m(%d,%s,%d) -> ",i,print(i,j),k);
                    //printf("(%d,%s,%d)\033[0m\n",i-k,print(i-k,j>>k),0);
                    //len=i-k,split=0,status=j>>k
                }
                if(last0[k]!=-1){//then link to s0[t']
                    //len=i-(k-last0-1), split=last0  status= ((j>>(k-last0+1)) & ((~0)<<(last0+1))) | (j&((1<<(last0))-1))
                    int i2=i-(k-last0[k]-1),j2=((j>>(k-last0[k]-1)) & ((~0)<<(last0[k]+1))) | (j&((1<<(last0[k]))-1)),k2=last0[k];
                    f(i2,j2,k2)+=f(i,j,k);
                    //printf("i2=%d\n",i2);
                    //printf("go 0: \033[32m(%d,%s,%d) -> ",i,print(i,j),k);
                    //printf("(%d,%s,%d)\033[0m\n",i2,print(i2,j2),k2);
                }
                if(last1[k]!=-1){//then link to s1[t']
                    //len=i-(k-last1-1), split=last1  status= ((j>>(k-last1+1)) & ((~0)<<(last1+1))) | (1<<(last1)) | (j&((1<<(last1))-1))
                    int i2=i-(k-last1[k]-1),j2=((j>>(k-last1[k]-1)) & ((~0)<<(last1[k]+1))) | (1<<(last1[k])) | (j&((1<<(last1[k]))-1)),k2=last1[k];
                    f(i2,j2,k2)+=f(i,j,k);
                    //printf("i2=%d\n",i2);
                    //printf("go 1: \033[32m(%d,%s,%d) -> ",i,print(i,j),k);
                    //printf("(%d,%s,%d)\033[0m\n",i2,print(i2,j2),k2);
                }
            }
        }
    }
}
char x[1<<21];
int main(){
    scanf("%d%d",&n,&k);
    FOR(i,0,n){
        scanf("%s",x);
        int lim=1<<i;
        FOR(j,0,lim-1){
            if(x[j]=='1'){
                f(i,j,i)++;
            }
        }
    }
    build();
    ROF(i,n,0){
        int lim=1<<i;
        FOR(j,0,lim-1){
            if(f(i,j,0)>=k){
                ROF(l,i-1,0)printf("%d",j>>l&1);
                return 0;
            }
        }
    }
    puts("ERROR!");
    exit(1);
    return 0;
}


Measured memory_bytes: 173312