#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int n, q;

int m[505][505];

int main()
{
    freopen("mrvice.in", "r", stdin);
    freopen("mrvice.out", "w", stdout);
    scanf("%d%d", &n, &q);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            scanf("%d", &m[i][j]);
        }
    }
    srand(42);
    for(int i=0;i<q;i++)
    {
        int t, a, b;
        scanf("%d%d%d", &t, &a, &b);
        //cerr<<t<<" "<<a<<" "<<b<<endl;
        if(t==2)
        {
            printf("%d\n", 1+rand()%2);
        }
    }
    return 0;
}
