#include <bits/stdc++.h>
using namespace std;
int n;
int a[1024][1024];
int b[1024];
void read() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
}
void solve() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    b[i] = a[i][i];
    ans += b[i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int type, x;
    scanf("%d", &type);
    if (type == 3) {
      ans = ans & 1;
      printf("%d", ans);
    } else {
      scanf("%d", &x);
      --x;
      ans -= b[x];
      b[x] ^= 1;
      ans += b[x];
      ans = (ans + 4) & 1;
    }
  }
  printf("\n");
}
int main() {
  read();
  solve();
  return 0;
}
