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 <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <random>

using namespace std;

#define repa(i, a, b) for (auto i = (a); i <= (b); ++i)
#define repd(i, a, b) for (auto i = (a); i >= (b); --i)
#define forz(i, n) for (auto i = 0; i < n; ++i)
#define fori(i, n) for (auto i = 1; i <= n; ++i)
#define fore(i, t) for (auto &&i : t)
#define all(x) (x).begin(), (x).end()
#define repmin(x, y) x = min(x, y)
#define repmax(x, y) x = max(x, y)
#define ll long long
#define lll __int128
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(t) ((int)(t).size())
#define vi vector<int>
#define vs vector<string>
#define vd vector<ld>
#define inf 1000000100
#define neginf -1000000100
#define DBG(var) cerr << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T1, typename T2>
ostream &operator<<(ostream &s, pair<T1, T2> &t) {
  return s << "(" << t.first << "," << t.second << ")";
}

template <typename T> 
ostream &operator<<(ostream &s, vector<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> 
ostream &operator<<(ostream &s, set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T> 
ostream &operator<<(ostream &s, unordered_set<T> &t) {
  s << "{ ";
  fore(x, t) s << x << " ";
  s << "}";
  return s;
}

template <typename T, typename S>
ostream &operator<<(ostream &s, map<T, S> &m) {
  s << "{ ";
  for (auto i = m.begin(); i != m.end(); i++)
    s << "(" << i->first << " -> " << i->second << ") ";
  s << "}";
  return s;
}

// globals
//

void preproc() {
  // add any preprocessing valid for all tests here
  //
}

void single(int testId) {
  // add code here
  //
  int n, m;
  string s;

  cin >> n >> m;

  double eps = 0.1;
  vd w(n, 1.0/n);

  forz(i, m) {
    discrete_distribution<int> dd(all(w));
    cin >> s;
    cout << s[dd(rng)] << "\n" << flush; 

    char r;
    cin >> r;

    forz(k, n) { if (s[k] != r) { w[k] *= (1 - eps); } }
    double norm = accumulate(all(w), 0.0);
    forz(k, n) { w[k] /= norm; }
  }
}

void multiple() {
  // multiple tests in single file
  int T;
  cin >> T;
  for (auto t = 1u; t <= T; t++)
    single(t);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  preproc();

  single(0);
  // multiple();

  return 0;
}