#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
using namespace std;
#define MAXN 21
int k , n , dp[1 << 21][21];
char ch[1 << 21];
int main() {
    cin >> n >> k;
    for( int i = 0 ; i <= n ; ++ i ) {
        scanf("%s",ch);
        for( int j = 0 ; j < ( 1 << i ) ; ++ j )
            dp[( 1 << i ) | j][i] = ( ch[j] == '1' );
    }
    int re1 = 0 , re2 = 0;
    for( int i = n ; i >= 0 ; -- i ) {
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) // sta : ( 1 << i ) | j
            for( int k = i ; k > 0 ; -- k ) if( dp[( 1 << i ) | j][k] ) {
                int S = ( j >> k ) , T = ( j & ( 1 << k ) - 1 ) , f = dp[( 1 << i ) | j][k];
                dp[( 1 << i - k ) | S][0] += f;
                int ls = T & ( 1 << k ) - 1 , re = (~T) & ( 1 << k ) - 1;
                if( T ) {
                    int u = 31 - __builtin_clz( ls );
//                    cout << ls << ' ' << u << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( 1 << u ) | ( T & ( 1 << u ) - 1 )][u] += f;
                }
                if( re ) {
                    int u = 31 - __builtin_clz( re );
//                    cout << T << ' ' << u << ' ' << k << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( T & ( 1 << u ) - 1)][u] += f;
                }
            }
    }
    for( int i = n ; i >= 0 ; -- i )
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) if( dp[( 1 << i ) | j][0] >= k ) {
            for( int k = i - 1 ; k >= 0 ; -- k ) printf("%1d",( j >> k ) & 1);
            return 0;
        }
}