Problem: The popular improv website Interpretation Impetus hosts regular improv contests and maintains a rating of the best performers. However, since improv can often go horribly wrong, the website is notorious for declaring improv contests unrated. It now holds a wager before each improv contest where the participants try to predict whether it will be rated or unrated, and they are now more popular than the improv itself.

Izzy and n other participants take part in each wager. First, they each make their prediction, expressed as 1 ("rated") or 0 ("unrated"). Izzy always goes last, so she knows the predictions of the other participants when making her own. Then, the actual competition takes place and it is declared either rated or unrated.

You need to write a program that will interactively play as Izzy. There will be m wagers held in 2021, and Izzy's goal is to have at most 1.3⋅ b + 100 wrong predictions after all those wagers, where b is the smallest number of wrong predictions that any other wager participant will have after all those wagers. 

The number b is not known in advance. Izzy also knows nothing about the other participants — they might somehow always guess correctly, or their predictions might be correlated. Izzy's predictions, though, do not affect the predictions of the other participants and the decision on the contest being rated or not — in other words, in each test case, your program always receives the same inputs, no matter what it outputs.

Interaction

First, a solution must read two integers n (1 ≤ n ≤ 1000) and m (1 ≤ m ≤ 10 000). Then, the solution must process m wagers. For each of them, the solution must first read a string consisting of n 0s and 1s, in which the i-th character denotes the guess of the i-th participant. Then, the solution must print Izzy's guess as 0 or 1. Don't forget to flush the output after printing it! Then, the solution must read the actual outcome, also as 0 or 1, and then proceed to the next wager, if this wasn't the last one. 

Your solution will be considered correct if it makes at most 1.3⋅ b + 100 mistakes, where b is the smallest number of mistakes made by any other participant. Note that if a solution outputs anything except 0 or 1 for a wager, it will be considered incorrect even if it made no other mistakes. 

There are 200 test cases in this problem.

Example

Input


3 4
000

1
100

1
001

0
111

1


Output




0


0


1


1

Note

In the example, the participants made 1, 2, and 3 mistakes respectively, therefore b=1 (the smallest of these numbers). Izzy made 3 mistakes, which were not more than 1.3⋅ b + 100=101.3, so these outputs are good enough to pass this test case (as are any other valid outputs).

Solution (in CPP):

Solution:
#include "bits/stdc++.h"
using namespace std;
#define REP(a,b) for(int a = 0;a < b;++a)
#define ld long double
ld prob[20000];
ld die_prob[20000];
int cnter[20000];
int n,m;
ld Winning_prob[20000];
int real_ans = 0;
string read_predict(){
  Winning_prob[0] = 1;
  string s;
#ifdef DEBUG
  real_ans = rand() % 2;
  int x = real_ans;
  REP(i,n){
    float hoge = (float)(rand()) / ((float)(RAND_MAX));
    if(hoge >= Winning_prob[i]){
      s.push_back((x^1) + '0');
    }else{
      s.push_back((x)+'0');
    }
  }
  cout << s << endl;
  cout << real_ans << endl;
#else
  cin >> s;
#endif
  return s;
}
int receive_score(int x){
  cout << x << endl;
  int y = real_ans;
#ifndef DEBUG
  cin >> y;
#endif
  return y;
}
void solve(){
#ifdef DEBUG
  n = 1000;
  m = 10000;
#else
  cin >> n >> m;
#endif
  int penalty = 0;
  REP(i,n){
    prob[i] = 1;
    die_prob[i] = 0;
    Winning_prob[i] = 0.0 + (float)(rand()) / ((float)(10.0 * RAND_MAX));;
  }
  REP(q,m){
    string s = read_predict();
    ld percent[2] = {};
    for(int i = 0;i < s.length();++i){
      percent[s[i] - '0'] += prob[i];//* prob[i] * prob[i];
      percent[(s[i] - '0') ^ 1] += die_prob[i];//* die_prob[i] * die_prob[i];
    }
    int hoge;
    if(percent[0] < percent[1]){
      hoge = receive_score(1);
      if(hoge != 1) penalty++;
    }else{
      hoge = receive_score(0);
      if(hoge != 0) penalty++;
    }
    for(int i = 0;i < s.length();++i){
      if(s[i] != '0' + hoge){
        cnter[i]++;
        die_prob[i] += prob[i] * 0.20L;
        prob[i] *= 0.80L;
      }else{
        prob[i] += die_prob[i] * 0.20L;
        die_prob[i] *= 0.80L;
      }
    }
  }
  int hoge = 1e9;
  REP(i,n){
    hoge = min(hoge,cnter[i]);
  }
#ifdef DEBUG
  if((double)hoge * 1.3 + 100 < penalty){
    throw runtime_error("Wrong Answer!");
  }
#endif
}
int main(){
  srand(time(NULL));
  int t = 1;
  REP(tea,t){
    solve();
  }
}