#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<string> stuff(n+1);
	for(int i = 0; i <= n; i++) cin >> stuff[i];
	vector<vector<int> > s(1, vector<int>(1 << (n+1)));
	for(int i = 0; i <= n; i++){
		for(int a = 0; a < (1 << i); a++){
			s[0][a + (1 << i)] = stuff[i][a] - '0';
		}
	}
	vector<vector<int> > ans(n+1);
	for(int b = 0; b <= n; b++){
		vector<int> cnt(1 << b, 0);
		for(int i = 0; i < (1 << b); i++){
			for(int x : s[i]){
				cnt[i] += x;
			}
		}
		ans[b] = cnt;
		if(b == n) break;

		vector<vector<int> > news(1 << (b+1), vector<int>(1 << (n-b), 0));
		for(int len = 1; len <= n-b; len++){
			for(int q = 0; q < 2; q++){
				int st = (1 << (len - 1)) - (1 - q);
				for(int a = st; a < (1 << (n+1-b)); a += (1 << len)){
					for(int i = 0; i < (1 << b); i++){
						news[i + (q << b)][a >> len] += s[i][a];
					}
				}
			}
		}
		for(int i = 0; i < (1 << (b+1)); i++){
			news[i][0] = 0;
		}
		s = news;
	}
	for(int b = n; b >= 0; b--){
		for(int i = 0; i < (1 << b); i++){
			if(ans[b][i] >= k){
				for(int x = b-1; x >= 0; x--){
					cout << ((i >> x) & 1);
				}
				cout << '\n';
				return 0;
			}
		}
	}
}