#include <bits/stdc++.h>
const int N = 1005;
int a[N][N];
int main() {
  int n, i, j, v = 0;
  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++) {
    for (j = 0; j < n; j++) v ^= (a[i][j] & a[j][i]);
  }
  int m;
  scanf("%d", &m);
  while (m--) {
    int t;
    scanf("%d", &t);
    if (t == 3)
      printf("%d", v);
    else {
      scanf("%d", &t);
      v ^= 1;
    }
  }
  return 0;
}
