#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 22;

vector<vector<int>> F[MAX_N];

vector<bool> exist[MAX_N];

int N, K;

void calc(int len, int val, int split) {
    int &res = F[len][val][split];
    if (split == 0) {
        res += exist[len][val];
        if (len < N) {
            res += F[len + 1][val][split];
            res += F[len + 1][val + (1 << len)][split];
        }
    } else {
        int pre = val & (1 << split) - 1, suf = val >> split;
        res += F[len][(pre >> 1) + (suf << split - 1) + ((pre & 1) << len - 1)][split - 1];
        if (len < N) {
            res += F[len + 1][val + (((pre & 1) ^ 1) << len)][split];
        }
    }
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i <= N; i++) {
        char buf[1 << MAX_N]; scanf("%s", buf);
        exist[i].resize(1 << i);
        for (int j = 0; j < 1 << i; j++) exist[i][j] = buf[j] == '1';
    }
    for (int i = 0; i <= N; i++) {
        F[i].resize(1 << i, vector<int>(i + 1));
    }
    for (int len = N; len >= 0; len--) {
        for (int split = 0; split <= len; split++) {
            for (int val = 0; val < 1 << len; val++) {
                calc(len, val, split);
            }
        }
    }
    for (int i = N; i >= 0; i--) {
        for (int j = 0; j < 1 << i; j++) {
            if (F[i][j][i] >= K) {
                for (int k = i - 1; k >= 0; k--)
                    printf("%d", j >> k & 1);
                printf("\n");
                return 0;
            }
        }
    }
}
