/*
ÏÔÈ»ÊÇ¿¼ÂÇ¶ÔÓÚÃ¿¸ö´®S£¬¼ÆÊýËüÊÇ¶àÉÙ¸ö´®µÄ×ÓÐòÁÐ
¿¼ÂÇÕâÃ´Ò»¸ö×´Ì¬(S, T)±íÊ¾ÏÖÔÚÓÐÒ»¸ö´®S£¬ËüºóÃæÐèÒª½ÓÒ»¸öTµÄ×ÓÐòÁÐ
×ªÒÆ¾ÍÀàËÆ×ÓÐòÁÐ×Ô¶¯»úÉÏ×ßµÄ¹ý³Ì£¬ÔÚºóÃæÌí¼Ó0ºÍÌí¼Ó1·Ö±ð¿ÉÒÔ×ßµ½Á½¸ö×´Ì¬£¬»¹ÓÐÒ»¸ö×ªÒÆÊÇ²»¼ÓÈÎºÎ×Ö·ûÈ»ºó½áÊø¡£ÕâÑù¾Í¹¹³ÉÁËÒ»¸öDAG
Í¬Ê±Õâ¸öDAGÓÐÒ»¸öºÜºÃµÄÐÔÖÊ£¬ÒòÎªÊÇÓÃ×ÓÐòÁÐ×Ô¶¯»úµÄ·½·¨¹¹³öÀ´µÄ£¬ËùÒÔÒ»¸öµãµ½ÁíÒ»¸öµãµÄÂ·¾¶×î¶àÖ»ÓÐÒ»¸ö
ËùÒÔ£¬Èç¹ûSºÍTµÄ×ÓÐòÁÐ£¬ÄÇÃ´µ±ÇÒ½öµ±(¿Õ´®, T)¿ÉÒÔ×ßµ½(S, ¿Õ´®)¡£ÒòÎªÂ·¾¶Î¨Ò»£¬ËùÒÔÖ±½ÓÔÚDAGÉÏ×öÂ·¾¶¼ÆÊý¼´¿É
*/
/*
ÕâµÀÌâµÄÇÉÃîÖ®´¦ÔÚÓÚ£¬¿¼ÂÇ¶ÔÓÚÃ¿¸ö¼¯ºÏÖÐµÄ´®S£¬ÈÃËü¶ÔËüµÄËùÓÐ×ÓÐòÁÐ²»ÖØ²»Â©µÄ²úÉú¹±Ï×
±©Á¦Ö»ÄÜÊÇ¶ÔÓÚÃ¿¸ö´®ÔÚ×ÓÐòÁÐ×Ô¶¯»úÉÏ×ß¡£µ«ÊÇÈç¹û×¢Òâµ½¿ÉÒÔÑ¹×ÓÐòÁÐ×Ô¶¯»ú£¬ÒÔ¼°ºóÃæÒ»Ð©Ïà¹ØµÄÐÔÖÊ£¬ÕâÌâ¾ÍÓ­ÈÐ¶ø½âÁË
*/

#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(20);
typedef pair<int, int> pil;
#define fi first
#define se second
#define mp make_pair

int N, K, M[Max_N + 1][1 << Max_N], F[Max_N + 1][1 << (Max_N + 1)];
char input[(1 << Max_N) + 5];
pil Next[Max_N + 1][1 << Max_N][2];

int main()
{
	scanf("%d%d", &N, &K);
	for (int Cnt = 0, len = 0;len <= N;++len)
		for (int S = 0;S < (1 << len);++S)
			M[len][S] = Cnt++;
	for (int i = 0;i <= N;++i)
	{
		scanf("%s", input);
		for (int j = 0;j < (1 << i);++j)
			if (input[j] - '0')
				F[0][M[i][j]] = 1;
	}
	for (int len = 0;len <= N;++len)
		for (int S = 0;S < (1 << len);++S)
			for (int c = 0;c <= 1;++c)
			{
				Next[len][S][c] = mp(-1, -1);
				for (int i = len - 1, _S = S;i >= 0;--i)
				{
					_S -= (S & (1 << i));
					if (((S & (1 << i)) != 0) == c)
					{
						Next[len][S][c] = mp(i, _S);
						break;
					}
				}
			}
	for (int Sumlen = N;Sumlen >= 0;--Sumlen)
		for (int i = 0, j;i <= Sumlen;++i)
		{
			j = Sumlen - i;
			for (int S = 0, pos, S1, S2;S < (1 << Sumlen);++S)
			{
				if (!F[i][pos = M[Sumlen][S]])
					continue;
				S1 = (S >> j), S2 = S - (S1 << j);
				if (j)
					F[i][M[i][S1]] += F[i][pos];
				for (int c = 0, _i, _S1, _j, _S2;c <= 1;++c)
					if (Next[j][S2][c].fi != -1)
					{
						_i = i + 1;
						_S1 = (S1 << 1) + c;
						_j = Next[j][S2][c].fi;
						_S2 = Next[j][S2][c].se;
						F[_i][M[_i + _j][(_S1 << _j) + _S2]] += F[i][pos];
					}
			}
		}
	for (int len = N;len >= 0;--len)
		for (int S = 0;S < (1 << len);++S)
			if (F[len][M[len][S]] >= K)
			{
				for (int j = len - 1;j >= 0;--j)
					printf("%d", (S & (1 << j)) != 0);
				return 0;
			}
	return 0;
}
### Prompt

Your challenge is to write a cpp solution to the following problem:

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
/*
ÏÔÈ»ÊÇ¿¼ÂÇ¶ÔÓÚÃ¿¸ö´®S£¬¼ÆÊýËüÊÇ¶àÉÙ¸ö´®µÄ×ÓÐòÁÐ
¿¼ÂÇÕâÃ´Ò»¸ö×´Ì¬(S, T)±íÊ¾ÏÖÔÚÓÐÒ»¸ö´®S£¬ËüºóÃæÐèÒª½ÓÒ»¸öTµÄ×ÓÐòÁÐ
×ªÒÆ¾ÍÀàËÆ×ÓÐòÁÐ×Ô¶¯»úÉÏ×ßµÄ¹ý³Ì£¬ÔÚºóÃæÌí¼Ó0ºÍÌí¼Ó1·Ö±ð¿ÉÒÔ×ßµ½Á½¸ö×´Ì¬£¬»¹ÓÐÒ»¸ö×ªÒÆÊÇ²»¼ÓÈÎºÎ×Ö·ûÈ»ºó½áÊø¡£ÕâÑù¾Í¹¹³ÉÁËÒ»¸öDAG
Í¬Ê±Õâ¸öDAGÓÐÒ»¸öºÜºÃµÄÐÔÖÊ£¬ÒòÎªÊÇÓÃ×ÓÐòÁÐ×Ô¶¯»úµÄ·½·¨¹¹³öÀ´µÄ£¬ËùÒÔÒ»¸öµãµ½ÁíÒ»¸öµãµÄÂ·¾¶×î¶àÖ»ÓÐÒ»¸ö
ËùÒÔ£¬Èç¹ûSºÍTµÄ×ÓÐòÁÐ£¬ÄÇÃ´µ±ÇÒ½öµ±(¿Õ´®, T)¿ÉÒÔ×ßµ½(S, ¿Õ´®)¡£ÒòÎªÂ·¾¶Î¨Ò»£¬ËùÒÔÖ±½ÓÔÚDAGÉÏ×öÂ·¾¶¼ÆÊý¼´¿É
*/
/*
ÕâµÀÌâµÄÇÉÃîÖ®´¦ÔÚÓÚ£¬¿¼ÂÇ¶ÔÓÚÃ¿¸ö¼¯ºÏÖÐµÄ´®S£¬ÈÃËü¶ÔËüµÄËùÓÐ×ÓÐòÁÐ²»ÖØ²»Â©µÄ²úÉú¹±Ï×
±©Á¦Ö»ÄÜÊÇ¶ÔÓÚÃ¿¸ö´®ÔÚ×ÓÐòÁÐ×Ô¶¯»úÉÏ×ß¡£µ«ÊÇÈç¹û×¢Òâµ½¿ÉÒÔÑ¹×ÓÐòÁÐ×Ô¶¯»ú£¬ÒÔ¼°ºóÃæÒ»Ð©Ïà¹ØµÄÐÔÖÊ£¬ÕâÌâ¾ÍÓ­ÈÐ¶ø½âÁË
*/

#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(20);
typedef pair<int, int> pil;
#define fi first
#define se second
#define mp make_pair

int N, K, M[Max_N + 1][1 << Max_N], F[Max_N + 1][1 << (Max_N + 1)];
char input[(1 << Max_N) + 5];
pil Next[Max_N + 1][1 << Max_N][2];

int main()
{
	scanf("%d%d", &N, &K);
	for (int Cnt = 0, len = 0;len <= N;++len)
		for (int S = 0;S < (1 << len);++S)
			M[len][S] = Cnt++;
	for (int i = 0;i <= N;++i)
	{
		scanf("%s", input);
		for (int j = 0;j < (1 << i);++j)
			if (input[j] - '0')
				F[0][M[i][j]] = 1;
	}
	for (int len = 0;len <= N;++len)
		for (int S = 0;S < (1 << len);++S)
			for (int c = 0;c <= 1;++c)
			{
				Next[len][S][c] = mp(-1, -1);
				for (int i = len - 1, _S = S;i >= 0;--i)
				{
					_S -= (S & (1 << i));
					if (((S & (1 << i)) != 0) == c)
					{
						Next[len][S][c] = mp(i, _S);
						break;
					}
				}
			}
	for (int Sumlen = N;Sumlen >= 0;--Sumlen)
		for (int i = 0, j;i <= Sumlen;++i)
		{
			j = Sumlen - i;
			for (int S = 0, pos, S1, S2;S < (1 << Sumlen);++S)
			{
				if (!F[i][pos = M[Sumlen][S]])
					continue;
				S1 = (S >> j), S2 = S - (S1 << j);
				if (j)
					F[i][M[i][S1]] += F[i][pos];
				for (int c = 0, _i, _S1, _j, _S2;c <= 1;++c)
					if (Next[j][S2][c].fi != -1)
					{
						_i = i + 1;
						_S1 = (S1 << 1) + c;
						_j = Next[j][S2][c].fi;
						_S2 = Next[j][S2][c].se;
						F[_i][M[_i + _j][(_S1 << _j) + _S2]] += F[i][pos];
					}
			}
		}
	for (int len = N;len >= 0;--len)
		for (int S = 0;S < (1 << len);++S)
			if (F[len][M[len][S]] >= K)
			{
				for (int j = len - 1;j >= 0;--j)
					printf("%d", (S & (1 << j)) != 0);
				return 0;
			}
	return 0;
}
```