Language: C++

#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int ui ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 22 * (1 << 22) ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n, m;

char s[maxn];

vector <int> edge[maxn];

int vertex[22][1 << 22], tot, f[maxn];

int get_id(int len, int pos, int x)
{
	if(vertex[pos][x + (1 << len)]) return vertex[pos][x + (1 << len)];
	return vertex[pos][x + (1 << len)] = ++tot;
}

void print(int len, int x)
{
	// if(!len) return (void)(printf("NULL"));
	per(i, len - 1, 0) putchar(((x & (1 << i)) != 0) + '0');
}

void build(int len, int pos, int x)
{
	// printf("\nbuild : %d %d ", len, pos);
	// print(len, x);
	// enter;

	get_id(len, pos, x);
	if(!pos) return ;
	edge[get_id(len, pos, x)].pb(get_id(len - pos, 0, x >> pos));
	
	// printf("t0 : %d %d ", len - pos, 0);
	// print(len - pos, x >> pos);
	// enter;
	
	int ori = x & (~((1 << pos) - 1)), real = x & ((1 << pos) - 1);
	x = real;
	if(x)
	{
		int tmp = 32 - __builtin_clz(x);
		int tmp2 = len - pos + tmp;
		x += (ori >> (pos - tmp));
		tmp --;
		edge[get_id(len, pos, ori + real)].pb(get_id(tmp2, tmp, x));
		
		// printf("to1 : %d %d ", tmp2, tmp);
		// print(tmp2, x);
		// enter;
	}
	x = real;
	x = (~x) & ((1 << pos) - 1);
	if(x)
	{
		int tmp = 32 - __builtin_clz(x);
		int tmp2 = len - pos + tmp;
		x -= (1 << tmp);
		x = (~x) & ((1 << tmp) - 1);
		x += (ori >> (pos - tmp));
		tmp --;
		edge[get_id(len, pos, ori + real)].pb(get_id(tmp2, tmp, x));
		
		// printf("to2 : %d %d ", tmp2, tmp);
		// print(tmp2, x);
		// enter;
	}
}

signed main()
{
	scanf("%d %d", &n, &m);
	rep(i, 0, n)
	{
		scanf("%s", s);
		rep(j, 0, (1 << i) - 1)
		{
			f[get_id(i, i, j)] = s[j] == '1';
			rep(k, 0, i) build(i, k, j);
		}
	}
	per(i, n, 0) rep(j, 0, (1 << i) - 1) per(k, i, 0)
	{
		// printf("now : %d %d ", i, k);
		// print(i, j);
		// enter;
		// printf("val : %d\n", f[get_id(i, k, j)]);
		if(f[get_id(i, k, j)] >= m)
		{
			print(i, j), enter;
			return 0;
		}
		for(int to : edge[get_id(i, k, j)]) f[to] += f[get_id(i, k, j)];
	}
	return 0;
}

Compiler output:
/tmp/ccN59iqq.o: in function `get_id(int, int, int)':
a.cc:(.text+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `vertex' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x6e): relocation truncated to fit: R_X86_64_PC32 against symbol `vertex' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x82): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `vertex' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0xd9): relocation truncated to fit: R_X86_64_PC32 against symbol `vertex' defined in .bss section in /tmp/ccN59iqq.o
/tmp/ccN59iqq.o: in function `main':
a.cc:(.text+0x416): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x4b2): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x56d): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccN59iqq.o
a.cc:(.text+0x584): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status