#include <bits/stdc++.h>

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 21, maxm = (1 << 20) | 10;

int n, m;
char s[maxn][maxm];
int dp[maxn][maxm], pd[maxn][maxm];

void transfer(int n, int S) {
	for (int i = 0; i <= n; ++i) {
		memcpy(pd[i], dp[i], sizeof(dp[i][0]) * S);
		memset(dp[i], 0, sizeof(dp[i][0]) * S);
	}
	int s1 = 0, s2 = S - 1;
	for (int i = n, s = S >> 1; i; --i, s >>= 1) {
		s2 ^= s;
		for (int j = 0, t; j < S; ++j) {
			if(t = pd[i][j]) {
				pd[i - 1][j] += t;
				if(i == n || ((j >> i) & 1) != ((j >> i - 1) & 1)) {
					dp[i - 1][((j & s1) >> 1) | (j & s2)] += t;
				}
			}
		}
		s1 ^= s;
	}
	return;
}

int main(int argc, char *argv[]) {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; ++i) {
		scanf("%s", s[i]);
	}
	for (int i = n; i; --i) {
		int S = 1 << i;
		for (int j = 0; j < S; ++j) {
			if(s[i][j] == '1') {
				++dp[i][j];
			}
			int cnt = 0;
			for (int k = 0; k <= i; ++k) {
				cnt += dp[k][j];
			}
			if(cnt >= m) {
				for (int k = i - 1; ~k; --k) {
					printf("%d", (j >> k) & 1);
				}
				putchar('\n');
				return 0;
			}
		}
		if(i > 1) {
			transfer(i, S);
		}
	}
	puts("");
	return 0;
}

