#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, k;
string x;
vector<vector<Int> > cnt[1 << 21];

Int dp[1 << 21];
Int log_2[1 << 21];
Int ans[21];

Int rev(Int l, Int x){
    Int res = 0;
    for(int i = 0;i < l;i++){
        res *= 2;
        res += x % 2;
        x /= 2;
    }
    return res;
}

void prepare(vector<vector<Int>> &vec, int n){
    for(int i = 0;i < n;i++){
        vec.push_back(vector<Int>(1 << i, 0));
    }
}

void dfs(Int x = 1, int dep = 0){
    if(dep > n)return;
    if(dep < n){
        prepare(cnt[x*2], n-dep);
        prepare(cnt[x*2+1], n-dep);
    }
    for(int i = 0;i <= n-dep;i++){
        for(int j = 0;j < (1<<i);j++){
            dp[x] += cnt[x][i][j];
            if(j+1 != (1<<i)){
                int neg = ~j;
                int first_zero = neg & -neg;
                int length = log_2[first_zero] + 1;
                cnt[x * 2][i-length][j >> length] += cnt[x][i][j];             
            }
            if(j != 0){
                int first_one = j & -j;
                int length = log_2[first_one] + 1;
                cnt[x * 2 + 1][i-length][j >> length] += cnt[x][i][j];             
            }
        }
    }
//    cout << x << " "  << dp[x] << endl;
    if(dp[x] >= k){
        if(ans[dep] == -1)ans[dep] = INF;
        ans[dep] = min(ans[dep], rev(dep, x));
        dfs(x * 2, dep + 1);
        dfs(x * 2 + 1, dep + 1);
    }
}

int main(){
    for(int i = 0;i < 21;i++){
        log_2[1 << i] = i;
        ans[i] = -1;
    }
    cin >> n >> k;
    prepare(cnt[1], n+1);
    for(int i = 0;i <= n;i++){
        cin >> x;
        for(int j = 0;j < (1<<i);j++){
            cnt[1][i][j] = x[j] - '0';
        }
    }

    dfs(1);

    for(int i = n;i >= 0;i--){
        if(ans[i] != -1){
            for(int j = i-1;j >= 0;j--){
                cout << (ans[i] >> j)%2;
            }cout << endl;
            break;
        }
    }
    
    return 0;
}
### Prompt

Construct a cpp code solution to the problem outlined:

You are given a set S of strings consisting of `0` and `1`, and an integer K.

Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.

Here, S is given in the format below:

* The data directly given to you is an integer N, and N+1 strings X_0,X_1,...,X_N. For every i (0\leq i\leq N), the length of X_i is 2^i.
* For every pair of two integers (i,j) (0\leq i\leq N,0\leq j\leq 2^i-1), the j-th character of X_i is `1` if and only if the binary representation of j with i digits (possibly with leading zeros) belongs to S. Here, the first and last characters in X_i are called the 0-th and (2^i-1)-th characters, respectively.
* S does not contain a string with length N+1 or more.



Here, a string A is a subsequence of another string B when there exists a sequence of integers t_1 < ... < t_{|A|} such that, for every i (1\leq i\leq |A|), the i-th character of A and the t_i-th character of B is equal.

Constraints

* 0 \leq N \leq 20
* X_i(0\leq i\leq N) is a string of length 2^i consisting of `0` and `1`.
* 1 \leq K \leq |S|
* K is an integer.

Input

Input is given from Standard Input in the following format:


N K
X_0
:
X_N


Output

Print the lexicographically smallest string among the longest strings that are subsequences of K or more different strings in S.

Examples

Input

3 4
1
01
1011
01001110


Output

10


Input

4 6
1
01
1011
10111010
1101110011111101


Output

100


Input

2 5
0
11
1111


Output

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, k;
string x;
vector<vector<Int> > cnt[1 << 21];

Int dp[1 << 21];
Int log_2[1 << 21];
Int ans[21];

Int rev(Int l, Int x){
    Int res = 0;
    for(int i = 0;i < l;i++){
        res *= 2;
        res += x % 2;
        x /= 2;
    }
    return res;
}

void prepare(vector<vector<Int>> &vec, int n){
    for(int i = 0;i < n;i++){
        vec.push_back(vector<Int>(1 << i, 0));
    }
}

void dfs(Int x = 1, int dep = 0){
    if(dep > n)return;
    if(dep < n){
        prepare(cnt[x*2], n-dep);
        prepare(cnt[x*2+1], n-dep);
    }
    for(int i = 0;i <= n-dep;i++){
        for(int j = 0;j < (1<<i);j++){
            dp[x] += cnt[x][i][j];
            if(j+1 != (1<<i)){
                int neg = ~j;
                int first_zero = neg & -neg;
                int length = log_2[first_zero] + 1;
                cnt[x * 2][i-length][j >> length] += cnt[x][i][j];             
            }
            if(j != 0){
                int first_one = j & -j;
                int length = log_2[first_one] + 1;
                cnt[x * 2 + 1][i-length][j >> length] += cnt[x][i][j];             
            }
        }
    }
//    cout << x << " "  << dp[x] << endl;
    if(dp[x] >= k){
        if(ans[dep] == -1)ans[dep] = INF;
        ans[dep] = min(ans[dep], rev(dep, x));
        dfs(x * 2, dep + 1);
        dfs(x * 2 + 1, dep + 1);
    }
}

int main(){
    for(int i = 0;i < 21;i++){
        log_2[1 << i] = i;
        ans[i] = -1;
    }
    cin >> n >> k;
    prepare(cnt[1], n+1);
    for(int i = 0;i <= n;i++){
        cin >> x;
        for(int j = 0;j < (1<<i);j++){
            cnt[1][i][j] = x[j] - '0';
        }
    }

    dfs(1);

    for(int i = n;i >= 0;i--){
        if(ans[i] != -1){
            for(int j = i-1;j >= 0;j--){
                cout << (ans[i] >> j)%2;
            }cout << endl;
            break;
        }
    }
    
    return 0;
}
```