JerryL/AlgoSimBench huggingface dataset:
1423_M. Milutin's Plums

As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an n by m matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions n by m.

At night, when he has spare time, he likes to perform various statistics on his trees. This time, he is curious to find out the height of his lowest tree. So far, he has discovered some interesting properties of his orchard. There is one particular property that he thinks is useful for finding the tree with the smallest heigh.

Formally, let L(i) be the leftmost tree with the smallest height in the i-th row of his orchard. He knows that L(i) ≤ L(i+1) for all 1 ≤ i ≤ n - 1. Moreover, if he takes a submatrix induced by any subset of rows and any subset of columns, L(i) ≤ L(i+1) will hold for all 1 ≤ i ≤ n'-1, where n' is the number of rows in that submatrix.

Since the season is at its peak and he is short on time, he asks you to help him find the plum tree with minimal height.

Input

This problem is interactive.

The first line of input will contain two integers n and m, representing the number of rows and the number of columns in Milutin's orchard. It is guaranteed that 1 ≤ n, m ≤ 10^6.

The following lines will contain the answers to your queries.

Output

Once you know have found the minimum value r, you should print ! r to the standard output.

Interaction

Your code is allowed to query for an entry (i, j) of a matrix (i.e. get the height of the tree which is in the i-th row and j-th column). The query should be formatted as ? i j, so that 1 ≤ i ≤ n and 1 ≤ j ≤ m.

You may assume that the entries of the matrix will be integers between 1 and 10^9.

Your solution should use not more than 4 ⋅ (n + m) queries.

This is an interactive problem. You have to use a flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout), in Java — System.out.flush(), in Pascal — flush(output) and in Python — sys.stdout.flush().

Example

Input


5 5
13 15 10 9 15
15 17 12 11 17
10 12 7 6 12
17 19 14 13 19
16 18 13 12 18


Output

Example input:
5 5
13 15 10 9 15
15 17 12 11 17
10 12 7 6 12
17 19 14 13 19
16 18 13 12 18


Example output:
? 2 1
? 2 2
? 4 2
? 4 3
? 2 3
? 4 4
? 4 5
? 4 1
? 1 1
? 3 1
? 3 2
? 3 3
? 5 3
? 5 4
? 5 5
! 6


Tags: interactive
Difficulty rating: 2800

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, mini, ans, jmin, v;
int query(int i, int j) {
  int ans;
  cout << "? " << i << ' ' << j << '\n';
  cout.flush();
  cin >> ans;
  return ans;
}
int main() {
  cin >> n >> m;
  mini = 1e9 + 1;
  ans = 1e9 + 1;
  for (j = 1; j <= m; j++) {
    v = query(1, j);
    if (v < mini) {
      mini = v;
      jmin = j;
    }
  }
  ans = mini;
  for (i = 1; i <= n; i++) ans = min(ans, query(i, jmin));
  cout << "! " << ans;
  return 0;
}
1430_G. Yet Another DAG Problem

You are given a directed acyclic graph (a directed graph that does not contain cycles) of n vertices and m arcs. The i-th arc leads from the vertex x_i to the vertex y_i and has the weight w_i.

Your task is to select an integer a_v for each vertex v, and then write a number b_i on each arcs i such that b_i = a_{x_i} - a_{y_i}. You must select the numbers so that:

  * all b_i are positive; 
  * the value of the expression ∑ _{i = 1}^{m} w_i b_i is the lowest possible. 



It can be shown that for any directed acyclic graph with non-negative w_i, such a way to choose numbers exists.

Input

The first line contains two integers n and m (2 ≤ n ≤ 18; 0 ≤ m ≤ (n(n - 1))/(2)).

Then m lines follow, the i-th of them contains three integers x_i, y_i and w_i (1 ≤ x_i, y_i ≤ n, 1 ≤ w_i ≤ 10^5, x_i ≠ y_i) — the description of the i-th arc.

It is guaranteed that the lines describe m arcs of a directed acyclic graph without multiple arcs between the same pair of vertices.

Output

Print n integers a_1, a_2, ..., a_n (0 ≤ a_v ≤ 10^9), which must be written on the vertices so that all b_i are positive, and the value of the expression ∑ _{i = 1}^{m} w_i b_i is the lowest possible. If there are several answers, print any of them. It can be shown that the answer always exists, and at least one of the optimal answers satisfies the constraints 0 ≤ a_v ≤ 10^9.

Examples

Input


3 2
2 1 4
1 3 2


Output


1 2 0


Input


5 4
1 2 1
2 3 1
1 3 6
4 5 8


Output


43 42 41 1337 1336


Input


5 5
1 2 1
2 3 1
3 4 1
1 5 1
5 4 10


Output


4 3 2 1 2

Example input:
5 4
1 2 1
2 3 1
1 3 6
4 5 8

3 2
2 1 4
1 3 2

5 5
1 2 1
2 3 1
3 4 1
1 5 1
5 4 10


Example output:
2 1 0 1 0 

1 2 0 

3 2 1 0 1 


Tags: bitmasks
dfs and similar
dp
flows
graphs
math
Difficulty rating: 2600

Solution:
#include<bits/stdc++.h>
using namespace std;
const int N=1<<18;
typedef long long LL;
int g[N],U[450],V[450],W[450],n,m;
bool h[N];
LL f[N];
int p[N],id,A[20];
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;++i)cin>>U[i]>>V[i]>>W[i],--U[i],--V[i];
	for(int S=0;S<1<<n;++S){
		for(int i=1;i<=m;++i)if((S>>U[i]&1)&&!(S>>V[i]&1))g[S]+=W[i];
		else if(!(S>>U[i]&1)&&(S>>V[i]&1)){g[S]=-1;break;}
		h[S]=1;
		for(int i=1;i<=m&&h[S];++i)
		if((S>>U[i]&1)&&(S>>V[i]&1))h[S]=0;
	}
	memset(f,0x3f,sizeof f);
	f[0]=0;
	for(int S=0;S<1<<n;++S)if(f[S]<1e18){
		int C=(1<<n)-1-S;
		for(int T=C;T;T=(T-1)&C)if(h[T]&&g[S|T]!=-1&&f[S|T]>f[S]+g[S|T])
		f[S|T]=f[S]+g[S|T],p[S|T]=T;
	}
	for(int S=(1<<n)-1,i=1;S;S^=p[S],++i){
		for(int j=0;j<n;++j)if(p[S]>>j&1)A[j]=i;
	}
	for(int i=0;i<n;++i)cout<<A[i]<<' ';
	return 0;
}
1436_F. Sum Over Subsets

You are given a multiset S. Over all pairs of subsets A and B, such that:

  * B ⊂ A; 
  * |B| = |A| - 1; 
  * greatest common divisor of all elements in A is equal to one; 



find the sum of ∑_{x ∈ A}{x} ⋅ ∑_{x ∈ B}{x}, modulo 998 244 353.

Input

The first line contains one integer m (1 ≤ m ≤ 10^5): the number of different values in the multiset S.

Each of the next m lines contains two integers a_i, freq_i (1 ≤ a_i ≤ 10^5, 1 ≤ freq_i ≤ 10^9). Element a_i appears in the multiset S freq_i times. All a_i are different.

Output

Print the required sum, modulo 998 244 353.

Examples

Input


2
1 1
2 1


Output


9


Input


4
1 1
2 1
3 1
6 1


Output


1207


Input


1
1 5


Output


560

Note

A multiset is a set where elements are allowed to coincide. |X| is the cardinality of a set X, the number of elements in it.

A ⊂ B: Set A is a subset of a set B.

In the first example B=\{1\}, A=\{1,2\} and B=\{2\}, A=\{1, 2\} have a product equal to 1⋅3 + 2⋅3=9. Other pairs of A and B don't satisfy the given constraints.

Example input:
1
1 5

4
1 1
2 1
3 1
6 1

2
1 1
2 1


Example output:
560

1207

9


Tags: combinatorics
math
number theory
Difficulty rating: 2800

Solution:
#include <bits/stdc++.h>
const int LIM = 1e5, MAX = LIM + 1, MOD = 998244353, INV8 = 873463809;
long long cnt[MAX], dp[MAX];
int mul(long long x, long long y) { return (x % MOD) * (y % MOD) % MOD; }
int pow(int x, long long y) {
  int res = 1;
  while (y > 0) {
    if (y % 2 == 1) res = mul(res, x);
    x = mul(x, x);
    y /= 2;
  }
  return res;
}
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int val, freq;
    scanf("%d%d", &val, &freq);
    cnt[val] += freq;
  }
  for (int i = LIM; i >= 1; --i) {
    long long size, sum, sqr;
    size = sum = sqr = 0;
    for (int j = i; j <= LIM; j += i) {
      size += cnt[j];
      sum += mul(cnt[j], j);
      sqr += mul(cnt[j], mul(j, j));
      dp[i] += MOD - dp[j] % MOD;
    }
    dp[i] += mul(mul(pow(2, size), INV8),
                 mul(mul(sum, sum), size) + mul(sqr, size - 2));
  }
  printf("%lld\n", dp[1] % MOD);
}
1446_A. Knapsack

You have a knapsack with the capacity of W. There are also n items, the i-th one has weight w_i. 

You want to put some of these items into the knapsack in such a way that their total weight C is at least half of its size, but (obviously) does not exceed it. Formally, C should satisfy: ⌈ W/2⌉ ≤ C ≤ W. 

Output the list of items you will put into the knapsack or determine that fulfilling the conditions is impossible. 

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights of items in the knapsack.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

The first line of each test case contains integers n and W (1 ≤ n ≤ 200 000, 1≤ W ≤ 10^{18}). 

The second line of each test case contains n integers w_1, w_2, ..., w_n (1 ≤ w_i ≤ 10^9) — weights of the items.

The sum of n over all test cases does not exceed 200 000.

Output

For each test case, if there is no solution, print a single integer -1. 

If there exists a solution consisting of m items, print m in the first line of the output and m integers j_1, j_2, ..., j_m (1 ≤ j_i ≤ n, all j_i are distinct) in the second line of the output — indices of the items you would like to pack into the knapsack.

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights items in the knapsack.

Example

Input


3
1 3
3
6 2
19 8 19 69 9 4
7 12
1 1 1 17 1 1 1


Output


1
1
-1
6
1 2 3 5 6 7

Note

In the first test case, you can take the item of weight 3 and fill the knapsack just right.

In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is -1.

In the third test case, you fill the knapsack exactly in half.

Example input:
3
1 3
3
6 2
19 8 19 69 9 4
7 12
1 1 1 17 1 1 1


Example output:
1
1 
-1
6
1 2 3 5 6 7 


Tags: constructive algorithms
greedy
sortings
Difficulty rating: 1300

Solution:
R=lambda:map(int,input().split())
t,=R()
for _ in[0]*t:
 n,w=R();r=[];i=s=0
 for x in R():
  i+=1
  if 2*x<w:r+=i,;s+=x
  elif x<=w:r=i,;s=x
  if 2*s>=w:print(len(r),*r);break
 else:print(-1)
1454_A. Special Permutation

You are given one integer n (n > 1).

Recall that a permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2, 3, 1, 5, 4] is a permutation of length 5, but [1, 2, 2] is not a permutation (2 appears twice in the array) and [1, 3, 4] is also not a permutation (n = 3 but there is 4 in the array).

Your task is to find a permutation p of length n that there is no index i (1 ≤ i ≤ n) such that p_i = i (so, for all i from 1 to n the condition p_i ≠ i should be satisfied).

You have to answer t independent test cases.

If there are several answers, you can print any. It can be proven that the answer exists for each n > 1.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

The only line of the test case contains one integer n (2 ≤ n ≤ 100) — the length of the permutation you have to find.

Output

For each test case, print n distinct integers p_1, p_2, …, p_n — a permutation that there is no index i (1 ≤ i ≤ n) such that p_i = i (so, for all i from 1 to n the condition p_i ≠ i should be satisfied).

If there are several answers, you can print any. It can be proven that the answer exists for each n > 1.

Example

Input


2
2
5


Output


2 1
2 1 5 3 4

Example input:
2
2
5


Example output:

2 1
2 1 5 3 4


Tags: constructive algorithms
probabilities
Difficulty rating: 800

Solution:
t=int(input())
while(t):
    n=int(input())
    print(n,*list(range(1,n)))
    t-=1
1461_C. Random Events

Ron is a happy owner of a permutation a of length n.

A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).

<image>

Ron's permutation is subjected to m experiments of the following type: (r_i, p_i). This means that elements in range [1, r_i] (in other words, the prefix of length r_i) have to be sorted in ascending order with the probability of p_i. All experiments are performed in the same order in which they are specified in the input data.

As an example, let's take a look at a permutation [4, 2, 1, 5, 3] and an experiment (3, 0.6). After such an experiment with the probability of 60\% the permutation will assume the form [1, 2, 4, 5, 3] and with a 40\% probability it will remain unchanged.

You have to determine the probability of the permutation becoming completely sorted in ascending order after m experiments.

Input

Each test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100).

The first line of each test case contains two integers n and m (1 ≤ n, m ≤ 10^5) — the length of the permutation and the number of experiments, respectively.

The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — contents of the permutation.

The following m lines of each test case each contain an integer r_i and a real number p_i (1 ≤ r_i ≤ n, 0 ≤ p_i ≤ 1) — the length of the prefix and the probability of it being sorted. All probabilities are given with at most 6 decimal places.

It is guaranteed that the sum of n and the sum of m does not exceed 10^5 (∑ n, ∑ m ≤ 10^5).

Output

For each test case, print a single number — the probability that after all experiments the permutation becomes sorted in ascending order. Your answer will be considered correct if its absolute or relative error does not exceed 10^{-6}.

Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.

Example

Input


4
4 3
4 3 2 1
1 0.3
3 1
4 0.6
5 3
4 2 1 3 5
3 0.8
4 0.6
5 0.3
6 5
1 3 2 4 5 6
4 0.9
5 0.3
2 0.4
6 0.7
3 0.5
4 2
1 2 3 4
2 0.5
4 0.1


Output


0.600000
0.720000
0.989500
1.000000

Note

Explanation of the first test case: It can be demonstrated that whether the final permutation is sorted or not depends solely on sorting being performed in the (4, 0.6) experiment.

Example input:
4
4 3
4 3 2 1
1 0.3
3 1
4 0.6
5 3
4 2 1 3 5
3 0.8
4 0.6
5 0.3
6 5
1 3 2 4 5 6
4 0.9
5 0.3
2 0.4
6 0.7
3 0.5
4 2
1 2 3 4
2 0.5
4 0.1


Example output:

0.600000
0.720000
0.989500
1.000000


Tags: dp
math
probabilities
Difficulty rating: 1500

Solution:
R=lambda:map(int,input().split())
t,=R()
for _ in[0]*t:
 n,m=R();a=1,*R()
 while a[n]==n:n-=1
 q=n>0
 for _ in[0]*m:r,p=input().split();q*=1-float(p)*(int(r)>=n)
 print(1-q)
147_B. Smile House

A smile house is created to raise the mood. It has n rooms. Some of the rooms are connected by doors. For each two rooms (number i and j), which are connected by a door, Petya knows their value cij — the value which is being added to his mood when he moves from room i to room j.

Petya wondered whether he can raise his mood infinitely, moving along some cycle? And if he can, then what minimum number of rooms he will need to visit during one period of a cycle?

Input

The first line contains two positive integers n and m (<image>), where n is the number of rooms, and m is the number of doors in the Smile House. Then follows the description of the doors: m lines each containing four integers i, j, cij и cji (1 ≤ i, j ≤ n, i ≠ j, - 104 ≤ cij, cji ≤ 104). It is guaranteed that no more than one door connects any two rooms. No door connects the room with itself.

Output

Print the minimum number of rooms that one needs to visit during one traverse of the cycle that can raise mood infinitely. If such cycle does not exist, print number 0.

Examples

Input

4 4
1 2 -10 3
1 3 1 -10
2 4 -10 -1
3 4 0 -3


Output

4

Note

Cycle is such a sequence of rooms a1, a2, ..., ak, that a1 is connected with a2, a2 is connected with a3, ..., ak - 1 is connected with ak, ak is connected with a1. Some elements of the sequence can coincide, that is, the cycle should not necessarily be simple. The number of rooms in the cycle is considered as k, the sequence's length. Note that the minimum possible length equals two.

Example input:
4 4
1 2 -10 3
1 3 1 -10
2 4 -10 -1
3 4 0 -3


Example output:
4


Tags: binary search
graphs
matrices
Difficulty rating: 2500

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, x, y, ans, F, d[10][310][310], f[310][310], g[310][310];
void C(int a[310][310], int b[310][310], int c[310][310]) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) a[i][j] = min(a[i][j], b[i][k] + c[k][j]);
}
int main() {
  cin >> n >> m;
  memset(d, 63, sizeof d);
  memset(f, 63, sizeof f);
  for (int i = 1; i <= n; i++) d[0][i][i] = f[i][i] = 0;
  for (int i = 1; i <= m; i++)
    cin >> a >> b >> x >> y, d[0][a][b] = -x, d[0][b][a] = -y;
  for (int i = 1; i <= 9; i++) C(d[i], d[i - 1], d[i - 1]);
  for (int i = 9; i >= 0; i--) {
    memset(g, 63, sizeof g);
    C(g, f, d[i]), F = 0;
    for (int j = 1; j <= n; j++)
      if (g[j][j] < 0) F = 1;
    if (!F) memcpy(f, g, sizeof g), ans += (1 << i);
  }
  cout << (ans > n * 2 ? 0 : ans + 1);
}
1497_C2. k-LCM (hard version)

It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n.

You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that:

  * a_1 + a_2 + … + a_k = n 
  * LCM(a_1, a_2, …, a_k) ≤ n/2 



Here LCM is the [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of numbers a_1, a_2, …, a_k.

We can show that for given constraints the answer always exists.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.

The only line of each test case contains two integers n, k (3 ≤ n ≤ 10^9, 3 ≤ k ≤ n).

It is guaranteed that the sum of k over all test cases does not exceed 10^5.

Output

For each test case print k positive integers a_1, a_2, …, a_k, for which all conditions are satisfied.

Example

Input


2
6 4
9 5


Output


1 2 2 1 
1 3 3 1 1 

Example input:
2
6 4
9 5


Example output:

1 2 2 1 
1 3 3 1 1 


Tags: constructive algorithms
math
Difficulty rating: 1600

Solution:
for _ in range(int(input())):
    n,k=map(int,input().split());a=[1]*(k-3);n-=k-3
    if not n%4:print(*a,n//2,n//4,n//4)
    elif not n%2:print(*a,n//2-1,n//2-1,2)
    else:print(*a,n//2,n//2,1)
1510_B. Button Lock

You are standing in front of the room with great treasures. The only thing stopping you is the door with a push-button combination lock. This lock has d buttons with digits from 0 to d - 1. Whenever you press a button, it stays pushed down. You can not pop back up just one button, but there is a "RESET" button — pressing it pops up all other buttons. Initially, no buttons are pushed down.

The door instantly opens when some specific set of digits is pushed down. Sadly, you don't know the password for it. Having read the documentation for this specific lock, you found out that there are n possible passwords for this particular lock. 

Find the shortest sequence of button presses, such that all possible passwords appear at least once during its execution. Any shortest correct sequence of button presses will be accepted.

Input

The first line contains two integers d and n (1 ≤ d ≤ 10; 1 ≤ n ≤ 2^d - 1). Next n lines describe possible passwords. Each line contains a string s_i of d zeros and ones: for all j from 1 to d the j-th character is 1 iff the button with the digit j - 1 must be pushed down.

All strings s_i are different, and each string contains at least one 1.

Output

On the first line, print the number k — the minimum number of button presses. On the second line, print k tokens, describing the sequence. Whenever you press a button with a digit, print that digit. Whenever you press "RESET", print "R".

Examples

Input


2 2
10
11


Output


2
0 1 


Input


3 4
001
111
101
011


Output


6
2 0 R 1 2 0 

Note

In the second example, the sequence 1 2 R 2 0 1 is also possible.

Example input:
3 4
001
111
101
011

2 2
10
11


Example output:

6
2 0 R 1 2 0 


2
0 1 


Tags: flows
graph matchings
graphs
Difficulty rating: 2600

Solution:
    #include<bits/stdc++.h>
    using namespace std;
    int i,j,k,n,m,d,sb,tmp,a[10500],pre;
    vector<int> v[10500];
    bool cmp(int a,int b){return __builtin_popcount(a)>__builtin_popcount(b);}
    int mch[10500];bool vis[10500];
    bool dfs(int u) {if (vis[u]) return 0;vis[u] = 1;for (auto i : v[u]) if ((mch[i] == 0) || dfs(mch[i])) {mch[i] = u;return 1;}return 0;}
    stack<int> s;
    int main(){scanf("%d%d",&d,&n);for(i=1;i<=n;i++)for(j=0;j<d;j++){scanf("%1d",&k);a[i]+=(k<<j);}
    	sort(a+1,a+n+1,cmp);for(i=1;i<=n;i++)for(j=1;j<=n;j++){if(i!=j&&(a[i]&a[j])==a[i]){v[i].push_back(j);}}for(i=1;i<=n;i++){memset(vis,0,sizeof(vis));dfs(i);}
    	memset(vis,0,sizeof(vis));for(i=1;i<=n;i++){if(vis[i]){continue;}s.push(-1);k=mch[i];pre=a[i];
    		while(k){vis[k]=1;for(j=0;j<d;j++)if((a[k]^pre)&(1<<j)){s.push(j);}	pre=a[k];k=mch[k];}
    		for(j=0;j<d;j++){if(pre&(1<<j)){s.push(j);}}}printf("%d\n",s.size()-1);
    	while(s.size()>1){if(s.top()==-1){printf("R ");}else{printf("%d ",s.top());}s.pop();}}
1523_D. Love-Hate

<image>

William is hosting a party for n of his trader friends. They started a discussion on various currencies they trade, but there's an issue: not all of his trader friends like every currency. They like some currencies, but not others.

For each William's friend i it is known whether he likes currency j. There are m currencies in total. It is also known that a trader may not like more than p currencies.

Because friends need to have some common topic for discussions they need to find the largest by cardinality (possibly empty) subset of currencies, such that there are at least ⌈ n/2 ⌉ friends (rounded up) who like each currency in this subset.

Input

The first line contains three integers n, m and p (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ p ≤ m ≤ 60, 1 ≤ p ≤ 15), which is the number of trader friends, the number of currencies, the maximum number of currencies each friend can like.

Each of the next n lines contain m characters. The j-th character of i-th line is 1 if friend i likes the currency j and 0 otherwise. It is guaranteed that the number of ones in each line does not exceed p.

Output

Print a string of length m, which defines the subset of currencies of the maximum size, which are liked by at least half of all friends. Currencies belonging to this subset must be signified by the character 1.

If there are multiple answers, print any.

Examples

Input


3 4 3
1000
0110
1001


Output


1000


Input


5 5 4
11001
10101
10010
01110
11011


Output


10001

Note

In the first sample test case only the first currency is liked by at least ⌈ 3/2 ⌉ = 2 friends, therefore it's easy to demonstrate that a better answer cannot be found.

In the second sample test case the answer includes 2 currencies and will be liked by friends 1, 2, and 5. For this test case there are other currencies that are liked by at least half of the friends, but using them we cannot achieve a larger subset size.

Example input:
3 4 3
1000
0110
1001

5 5 4
11001
10101
10010
01110
11011


Example output:

1000


10001


Tags: bitmasks
brute force
dp
probabilities
Difficulty rating: 2400

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define b(x) (1ll<<((x)-1))
int i,j,k,n,m,t;
char ch;
ll a[200500],r1,r2;
unordered_map<ll,int> mp,mp2;

int main(){
	mt19937_64 r(chrono::steady_clock::now().time_since_epoch().count()+1);
	long c=clock();
	scanf("%d%d%*d",&n,&m);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			ch=getchar();
			if(ch=='1'||ch=='0'){
				if(ch=='1'){a[i]|=b(j);}continue;
			}
			j--;
		}
	}
	while(clock()-c<=2600){
		int it=r()%n+1;mp.clear();mp2.clear();
		for(i=1;i<=n;i++){
			mp[a[i]&a[it]]++;
		}
		for(ll i=a[it];i;i=((i-1)&a[it])){
			k=mp[i];
			for(ll j=i;j;j=((j-1)&i)){
				mp2[j]+=k;
			}
			if(mp2[i]>=(n+1)/2){
				if(__builtin_popcountll(i)>r1){
					r1=__builtin_popcountll(i);r2=i;
				}
			}
		}
	}
	for(i=1;i<=m;i++){
		if(r2&b(i)){printf("1");}
		else{printf("0");}
	}
}