#include <bits/stdc++.h>
using namespace std;
const int maxn = 1002;
int a[maxn][maxn];
int n, q, s;
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  s = 0;
  for (i = 1; i <= n; ++i) s = (s + a[i][i] * a[i][i]) % 2;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &k);
    if (k < 3) {
      scanf("%d", &i);
      s = (s + 2 - a[i][i] * a[i][i]) % 2;
      a[i][i] = !a[i][i];
      s = (s + a[i][i] * a[i][i]) % 2;
    } else {
      printf("%d", s);
    }
  }
  puts("");
  return 0;
}
