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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 21;
const int MX = 1 << 20;
const int INF = TEN(9);

// len, pos, value
// dp : matched, remaining part

V<int> nx[maxn][maxn][2], dp[maxn][maxn];
string X[maxn];

int main() {
    int N, K;
    cin >> N >> K;

    for (int i = 0; i <= N; ++i) {
        cin >> X[i];
        rep(j, i + 1) {
            dp[i][j].resize(1 << i);
            rep(k, 2) nx[i][j][k].resize(1 << i, INF);
        }

        rep(x, 1 << i) {
            for (int j = i - 1; j >= 0; --j) {
                rep(k, 2) nx[i][j][k][x] = nx[i][j + 1][k][x];
                nx[i][j][(x >> (i - j - 1)) & 1][x] = j;
            }
        }

        rep(j, 1 << i) {
            if (X[i][j] == '1') {
                dp[i][0][j] = 1;
            }
        }
    }

    for (int i = N; i >= 0; --i) {
        for (int j = 0; j <= i; ++j) {
            rep(k, 1 << i) {
                // next character
                rep(c, 2) {
                    int pos = nx[i][j][c][k];
                    if (pos == INF) continue;
                    int i2 = j + i - pos;
                    int j2 = j + 1;
                    int k2 = ((k >> (i - j)) << (i - pos)) |
                             (k & ((1 << (i - pos)) - 1));
                    dp[i2][j2][k2] += dp[i][j][k];
                }
                // matched
                if (j != i) {
                    int k2 = k >> (i - j);
                    dp[j][j][k2] += dp[i][j][k];
                }
            }
        }
    }

    for (int i = N; i >= 0; --i) {
        rep(k, 1 << i) {
            if (dp[i][i][k] >= K) {
                string ans;
                int x = k;
                rep(t, i) { ans.pb('0' + (k >> t & 1)); }
                reverse(ALL(ans));
                cout << ans << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 498444