http://codeforces.com/problemset/problem/405/C
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std ;
bitset < 1002 > a[1002];
int n;
inline int Solve(){
int ret = 0;
for(int i=1;i<=n;++i)
ret += a[i][i];
return ret;
}
int main()
{
std::ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("date.in", "r", stdin);
freopen("date.out", "w", stdout);
#endif
int i,j;
scanf("%d\n",&n);
for(i=1;i<=n;++i)
for(j=1;j<=n;++j){
int x;
scanf("%d\n",&x);
a[i][j] = x;
}
int nr = Solve();
int q , x ,op;
scanf("%d\n",&q);
for( ;q; --q){
scanf("%d\n",&op);
if(op==1 || op == 2){
scanf("%d\n",&x);
if(a[x][x] == 1){
--nr;
a[x][x] = 0;
}
else{
++nr;
a[x][x] = 1;
}
}
else
cout<<(nr&1);
}
cout<<"\n";
return 0;
}