#include <bits/stdc++.h>
using namespace std;
int ar[1010][1010], ar00[1010], ar01[1010], ar10[1010], ar11[1010], diag[1010];
vector<int> vec;
int main() {
  int n, i, j, ans, prev, first, q, b;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &ar[i][j]);
      if (i == j) {
        diag[i] = ar[i][j];
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != j) {
        if (ar[i][j] == 0 && ar[j][i] == 0) {
          ar00[i]++;
          ar00[i]++;
        } else if (ar[i][j] == 0 && ar[j][i] == 1) {
          ar01[i]++;
          ar01[i]++;
        } else if (ar[i][j] == 1 && ar[j][i] == 0) {
          ar10[i]++;
          ar10[i]++;
        } else if (ar[i][j] == 1 && ar[j][i] == 1) {
          ar11[i]++;
          ar11[i]++;
        }
      }
    }
  }
  ans = 0;
  for (i = 0; i < n; i++) {
    ans = (ans + ar11[i] % 2) % 2;
  }
  for (i = 0; i < n; i++) {
    ans = (ans + diag[i] % 2) % 2;
  }
  scanf("%d", &q);
  while (q--) {
    int a;
    scanf("%d", &a);
    if (a == 1) {
      scanf("%d", &i);
      i--;
      prev = (ar11[i] + diag[i] % 2) % 2;
      int p, q, r, s;
      p = ar00[i];
      q = ar01[i];
      r = ar10[i];
      s = ar11[i];
      ar00[i] = r;
      ar10[i] = p;
      ar11[i] = q;
      ar01[i] = s;
      diag[i]++;
      first = (ar11[i] + diag[i] % 2) % 2;
      ans = ((ans + first - prev) % 2 + 2) % 2;
    } else if (a == 2) {
      scanf("%d", &i);
      i--;
      prev = (ar11[i] + diag[i] % 2) % 2;
      int p, q, r, s;
      p = ar00[i];
      q = ar01[i];
      r = ar10[i];
      s = ar11[i];
      ar11[i] = r;
      ar01[i] = p;
      ar00[i] = q;
      ar10[i] = s;
      diag[i]++;
      first = (ar11[i] + diag[i] % 2) % 2;
      ans = ((ans + first - prev) % 2 + 2) % 2;
    } else if (a == 3) {
      vec.push_back((ans + 2) % 2);
    }
  }
  for (vector<int>::iterator it = vec.begin(); it != vec.end(); it++) {
    printf("%d", (*it));
  }
}
