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;

bool home = 1;
typedef long long ll;
#define int ll
typedef long double ld;
typedef unsigned long long ull;

///signed realMain();

mt19937 rng_home(0);
mt19937 rng_oj((long long) (new char));

int rng() {
  if (home) {
    return rng_home();
  } else{
    return rng_oj();
  }
}

ull rng_ull() {
  return (ull) rng() * rng() ^ ((ull) rng() * rng());
}

int rng_range(int l, int r) {
  return l + abs(rng()) % (r - l + 1);
}
/**

signed main() {
#ifdef ONLINE_JUDGE
  home = 0;
#endif
  if (home) {
    freopen ("input", "r", stdin);
  } else {
    ios::sync_with_stdio(0); cin.tie(0);
  }
  realMain();
}**/

const int N = 10000 + 7;
///const int C = 10;
int C = 100;
int n, m, matching[N], now[N];
int tricked[N], lazy[N];

signed main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++) {
      now[i] = s[i - 1] - '0';
    }
    int s0 = 0, s1 = 0;
    for (int j = 1; j <= n; j++) {
      if (now[j] == 0) s0 += matching[j];
      else s1 += matching[j];
    }
    int me = (s1 >= s0);
    lazy[i] = 0;
    if (i - 1 >= C) {
      int cu = 0, fara = 0;
      for (int j = 0; j < C; j++) {
        int id = i - j - 1;
        if (tricked[id]) {
          cu++;
        } else {
          fara++;
        }
      }
      fara = C - cu;
      if (cu > fara) {
        lazy[i] = 1;
        me ^= 1;
      }
    }
    cout << me << endl;
    int sol;
    cin >> sol;
    tricked[i] = ((s1 >= s0) != sol);
    for (int i = 1; i <= n; i++) {
      matching[i] += (now[i] == sol);
    }
  }
  if (home) {
    for (int j = 1; j <= n; j++) {
      cout << matching[j] << " ";
    }
  }

  return 0;
}