#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
void swap(int &a, int &b) {
  int t = a;
  a = b;
  b = t;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i][i] == 1) ans ^= 1;
  int q;
  scanf("%d", &q);
  for (; q; --q) {
    int x, y;
    scanf("%d", &x);
    if (x == 3) {
      printf("%d", ans);
      continue;
    }
    scanf("%d", &y);
    if (x == 2) {
      if (a[y][y] == 1) ans ^= 1;
      a[y][y] ^= 1;
      if (a[y][y]) ans ^= 1;
    }
    if (x == 1) {
      if (a[y][y] == 1) ans ^= 1;
      a[y][y] ^= 1;
      if (a[y][y]) ans ^= 1;
    }
  }
  printf("\n");
}
