#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 9, mod2 = 1e9 + 7, p1 = 1124, p2 = 5938;
const double PI = 3.14159265359;
int n, m[1007][1007], a[1007], b[1007], c[1007], d[1007], L[1007];
void swap(int &a, int &b) {
  int t;
  t = a;
  a = b;
  b = t;
}
void sol() {
  int i, j, x, t, s = 0, q;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &m[i][j]);
    }
  }
  for (i = 0; i < 1007; i++) {
    a[i] = 0;
    b[i] = 0;
    c[i] = 0;
    d[i] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (m[i][j] == 0 && m[j][i] == 0) {
        a[i]++;
        a[i] %= 2;
      }
      if (m[i][j] == 0 && m[j][i] == 1) {
        b[i]++;
        b[i] %= 2;
      }
      if (m[i][j] == 1 && m[j][i] == 0) {
        c[i]++;
        c[i] %= 2;
      }
      if (m[i][j] == 1 && m[j][i] == 1) {
        d[i]++;
        d[i] %= 2;
      }
    }
  }
  for (i = 0; i < n; i++) {
    L[i] = m[i][i];
    s += d[i];
    s %= 2;
    if (L[i] == 0) {
      a[i]--;
      a[i] += 100;
      a[i] %= 2;
    } else {
      d[i]--;
      d[i] += 100;
      d[i] %= 2;
    }
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &x);
      x--;
      L[x] = (L[x] + 1) % 2;
      if (L[x] == 0) {
        s--;
      } else {
        s++;
      }
      s += 100;
      s %= 2;
    } else if (t == 2) {
      scanf("%d", &x);
      x--;
      L[x] = (L[x] + 1) % 2;
      if (L[x] == 0) {
        s--;
      } else {
        s++;
      }
      s += 100;
      s %= 2;
    } else {
      printf("%d", s);
    }
  }
  printf("\n");
}
int main() {
#pragma comment(linker, "/STACK:1073741824")
  while (scanf("%d", &n) != EOF) sol();
  return 0;
}
