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(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define per(i, n, a) for (int i = (n); i >= (int)(a); --i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int, int> PII;
mt19937 rnd(time(0));

#ifdef LOCAL_DEBUG
#define Log(format, ...)                                                       \
  printf("\33[1;34m[%s,%d,%s] " format "\33[0m\n", __FILE__, __LINE__,         \
         __func__, ##__VA_ARGS__)

#define Log2(format, ...)                                                      \
  printf("\33[1;35m[%s,%d,%s] " format "\33[0m\n", __FILE__, __LINE__,         \
         __func__, ##__VA_ARGS__)

#define Assert(cond, ...)                                                      \
  do {                                                                         \
    if (!(cond)) {                                                             \
      fflush(stdout);                                                          \
      fprintf(stderr, "\33[1;31m");                                            \
      fprintf(stderr, __VA_ARGS__);                                            \
      fprintf(stderr, "\33[0m\n");                                             \
      assert(cond);                                                            \
    }                                                                          \
  } while (0)

#define panic(...) Assert(0, __VA_ARGS__)
#else
#define Log(format, ...)
#define Log2(format, ...)
#define Assert(cond, ...)
#define panic(...)
#endif

inline int in() {
  char ch = getchar();
  int f = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return f * x;
}

const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 200010;

void Initialization() {
  // Remember to modify [inf, N, mod, ...]
}

int wrong[N];
typedef long double db;

db w[N];

db rand_double() {
  db x = rnd() % (1 << 16);
  return x / (db)(1 << 16);
}

void solve(int CaseNum) {
  int n = in(), m = in();
  w[0] = 1;
  rep(i, 1, 100) w[i] = w[i - 1] * 0.75;
  rep(_, 1, m) {
    Log("Turn %d", _);
    string s;
    cin >> s;
    int minl = inf;
    rep(i, 0, n - 1) minl = min(minl, wrong[i]);
    db sa = 0, sb = 0;
    rep(i, 0, n - 1) {
      if (s[i] == '0')
        sa += w[wrong[i] - minl];
      else
        sb += w[wrong[i] - minl];
    }
    db x = rand_double();
    int choose = x >= (sa / (sa + sb));
    cout << choose << endl;
    int actual;
    cin >> actual;
    rep(i, 0, n - 1) wrong[i] += (s[i] - '0') != actual;
  }
  // printf("Case #%d: ", CaseNum);
}

int main() {
#ifdef LOCAL_DEBUG
  // freopen("in.in", "r", stdin);
  // freopen("out.out", "w", stdout);
  clock_t _start_time = clock();
#endif
  int T = 1;
  // T = in();
  Initialization();
  rep(_, 1, T) solve(_);
#ifdef LOCAL_DEBUG
  Log2("Running Time: %.3lfs",
       ((double)clock() - _start_time) / CLOCKS_PER_SEC);
#endif
  return 0;
}