#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#ifndef ONLINE_JUDGE
//freopen("code.in", "r", stdin);
//freopen("code.out","w",stdout);
#endif

#define tplcf template <class c>
#define tplcfd template <class c, class b>
#define deout(X) operator<<(X)
#define recog(X) typename std::enable_if<sizeof dud<c>(0) X 1, debug &>::type

template <class c, class S = std::greater<c>, int L = 100000>
class sarr
{
public:
    c *a;
    int sa[L];
    sarr(c *a, int sl, int sr)
    {
        for (int i = sl; i <= sr; ++i)
            sa[i] = i;
        sort(sa + sl, sa + sr + 1, S());
    }
    c &operator[](const int &index) { return a[sa[index]]; }
};
tplcf sarr<c>
sortarr(c *arr, int sl, int sr)
{
    return sarr<c>(arr, sl, sr);
}

tplcf class suba
{
public:
    suba(c *a, int l, int r) : a(a), l(l), r(r) {}
    int l, r;
    c *a;
    c &operator[](const int &index) { return a[l + index]; }
    inline uint32_t len() { return r - l + 1; }
};
tplcf suba<c>
subarr(c *a, int l, int r)
{
    return suba<c>(a, l, r);
}

tplcf struct rge
{
    c b, e;
};
tplcf rge<c>
range(c i, c j) { return rge<c>{i, j}; }
tplcf auto dud(c *x) -> decltype(std::cerr << *x, 0);
tplcf char dud(...);
struct debug
{
#ifndef ONLINE_JUDGE
    ~debug()
    {
        std::cerr << std::endl;
    }
    tplcf recog(!=) deout(c i)
    {
        std::cerr << std::boolalpha << i;
        return *this;
    }
    tplcf recog(==) deout(c i)
    {
        return *this << range(begin(i), end(i));
    }
    tplcfd debug &operator<<(std::pair<b, c> d)
    {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    tplcf debug &deout(rge<c> d)
    {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << (char *)", " + 2 * (it == d.b) << *it;
        return *this << "]";
    }
    tplcf debug &deout(suba<c> sa)
    {
        *this << "{" << sa.l << ", " << sa.r << "}:" << range(sa.a + sa.l, sa.a + sa.r + 1);
        return *this;
    }
#else
    tplcf debug &deout(const c &)
    {
        return *this;
    }
#endif
};
#include <chrono>
class Timer
{
public:
    Timer() : t1(clock::now()) {}
    void tic()
    {
        t1 = clock::now();
    }
    void toc(const char *str)
    {
        t2 = clock::now();
        std::cerr << str << " time: " << std::chrono::duration_cast<res>(t2 - t1).count() / 1e3 << "ms." << std::endl;
    }

private:
    typedef std::chrono::high_resolution_clock clock;
    typedef std::chrono::microseconds res;
    clock::time_point t1, t2;
};

typedef long long ll;
#define FILE(X, Y)   \
    ifstream fin(X); \
    ofstream fout(Y)
#define FASTIO()                \
    cin.sync_with_stdio(false); \
    cin.tie(0);                 \
    cout.tie(0)
#define MP(X, Y) make_pair(X, Y)
#define imie(X) " [" << #X ": " << (X) << "] "
#ifndef ONLINE_JUDGE
#define PAUSE()      \
    system("pause"); \
    return 0
#else
#define PAUSE() return 0
#endif

#define INF 0x3f3f3f3f
#define INFM 0x3f

using namespace std;

int n, m;
double p[10005];
char s[10004];
int las = 1;

mt19937 mtrand(time(0));

int main(void)
{
    FASTIO();
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        p[i] = 1;
    }
    char t[3];
    for (int i = 1; i <= m; ++i)
    {
        cin >> s + 1;
        double c[2] = {0, 0};
        for (int j = 1; j <= n; ++j)
        {
            c[s[j] - '0'] += p[j];
        }
        cout << ((double(mtrand() % RAND_MAX) / double(RAND_MAX)) > (c[0] / (c[0] + c[1])) ? '1' : '0') << endl;
        cin >> t;
        for (int j = 1; j <= n; ++j)
        {
            if (s[j] != t[0])
                p[j] *= 0.8;
        }
    }
    PAUSE();
}