#include <bits/stdc++.h>
using namespace std;
const int N = 1003;
const int mod = 1e9 + 7;
int a[N][N];
int c[N];
int n;
int sum;
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (i = 0; i < n; i++) sum += a[i][i] * a[i][i];
  sum %= 2;
  int m;
  scanf("%d", &m);
  int op, x;
  while (m--) {
    scanf("%d", &op);
    if (op == 3) {
      printf("%d", sum);
    } else {
      scanf("%d", &x);
      sum = sum - a[x][x] + (a[x][x] ^ 1);
      a[x][x] ^= 1;
      sum &= 1;
    }
  }
  return 0;
}
