#include <iostream>

using namespace std;

int dp[21][(1 << 21)], f[21][(1 << 21)];

int main ()
{
int n, k;
cin >> n >> k;
for(int i = 0 ; i <= n ; ++i){
	string s;
	cin >> s;
	for(int j = 0 ; j < s.size() ; ++j){
		if(s[j] == '1'){
			dp[i][j] = 1;
		}
	}
}
for(int i = 1 ; i <= n ; ++i){
	for(int j = 0 ; j < (1 << i) ; ++j){
		int u = (j >> (i - 1)) & 1;
		int br = 0;
		while(br < i && ((j >> (i - br - 1)) & 1) == u){
			br++;
		}
		if(br == i){
			f[i][j] = -1;
		}
		else{
			f[i][j] = br;
		}
	}
}
for(int i = 0 ; i <= n ; ++i){
	for(int j = i + 1 ; j <= n ; ++j){
		int mask = (1 << (j - i)) - 1;
		for(int w = 0 ; w < (1 << j) ; ++w){
			dp[i][w >> (j - i)] += dp[j][w];
			int x = f[j - i][w & mask];
			if(x != -1){
				dp[j - x][((w >> (j - i)) << (j - i - x)) | (w & ((1 << (j - i - x)) - 1))] += dp[j][w];
			}
		}
	}
}
int sol, vel = -1;
for(int i = 0 ; i <= n ; ++i){
	for(int j = 0 ; j < (1 << i) ; ++j){
		if(dp[i][j] >= k){
			if(i > vel){
				vel = i;
				sol = j;
			}
		}
	}
}
for(int i = vel - 1 ; i >= 0 ; --i){
	cout << ((sol >> i) & 1);
}

return 0;
}
