#include <bits/stdc++.h>
const int N = 1010;
int sum[N];
int a[N][N];
int main() {
  int n, q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      sum[i] += a[i][j] * a[j][i];
      sum[i] %= 2;
    }
    ret += sum[i];
    ret %= 2;
  }
  scanf("%d", &q);
  while (q--) {
    int op;
    scanf("%d", &op);
    int i;
    if (op == 1 || op == 2) {
      scanf("%d", &i);
      ret ^= 1;
    } else {
      printf("%d", ret);
    }
  }
  return 0;
}
