#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x = 0;
  bool f = 0;
  char c;
  for (; (c = getchar()) < '0' || c > '9'; f = c == '-')
    ;
  for (x = c - '0'; (c = getchar()) >= '0' && c <= '9';
       x = (x << 3) + (x << 1) + c - '0')
    ;
  return f ? -x : x;
}
int res = 0, n, q, x, tp;
bool a[1005][1005];
int main() {
  n = in();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) a[i][j] = in();
  for (int i = 1; i <= n; ++i) res = (res + a[i][i]) % 2;
  q = in();
  while (q--) {
    tp = in();
    if (tp < 3) {
      x = in();
      a[x][x] ^= 1;
      res ^= 1;
    } else
      printf("%d", res);
  }
  return 0;
}
