#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e3) + 10;
int a[MAXN][MAXN], n, curAns, q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  }
  scanf("%d", &q);
  for (int i = 1; i <= n; i++) {
    curAns = (curAns + a[i][i]) % 2;
  }
  for (int i = 1; i <= q; i++) {
    short cmd;
    int x;
    scanf("%d", &cmd);
    if (cmd == 1 || cmd == 2) {
      scanf("%d", &x);
      curAns ^= 1;
    } else {
      printf("%d", curAns);
    }
  }
  return 0;
}
