#include <bits/stdc++.h>
using namespace std;
int N, x, ans, M, t;
int a[1010], f[1010];
int lowbit(int x) { return x & -x; }
void Init(int x, int data) {
  while (x <= N) {
    f[x] += data;
    x += lowbit(x);
  }
}
int calc(int x) {
  int res = 0;
  for (; x; x -= lowbit(x)) res += f[x];
  return res;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      scanf("%d", &x);
      if (i == j) {
        a[i] = x;
        Init(i, x);
      }
    }
  scanf("%d", &M);
  for (int i = 1; i <= M; i++) {
    scanf("%d", &t);
    if (t < 3) {
      scanf("%d", &x);
      Init(x, -a[x]);
      a[x] = 1 - a[x];
      Init(x, a[x]);
    } else {
      ans = calc(N);
      printf("%d", ans & 1);
    }
  }
}
