#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

inline int SH(int x) { return 1<<x; }
inline int BITS(int x) { return (1<<x)-1; }

int N, K;
char buf[(1<<20)+10];
int C[1<<21][21];

void MAIN() {
    scanf("%d%d", &N, &K);
    REP (t, N+1) {
	scanf("%s", buf);
	REP (i, SH(t)) if (buf[i] == '1') {
	    C[i | SH(t)][0]++;
	}
    }

    for (int t=N; t>=0; t--) REP (s, SH(t)) REP (i, t) if (C[s|SH(t)][i]) {
	int cur = C[s|SH(t)][i];
	int sub = s & BITS(i);

	// cut;
	C[sub|SH(i)][i] += cur;

	// 0;
	for (int k=i; k<t; k++) if (~s>>k&1) {
	    int hi = (s>>k)<<i;
	    C[hi|sub|SH(t-k+i)][i+1] += cur;
	    break;
	}

	// 1;
	for (int k=i; k<t; k++) if (s>>k&1) {
	    int hi = (s>>k)<<i;
	    C[hi|sub|SH(t-k+i)][i+1] += cur;
	    break;
	}
    }

    for (int t=N; t>=0; t--) REP (s, SH(t)) if (C[s|SH(t)][t] >= K) {
	for (int i=t; i--;) buf[t-1-i] = (s>>i&1) | '0';
	buf[t] = 0;
	puts(buf);
	return;
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

