#include <bits/stdc++.h>
int mat[1010][1010];
int counts = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) scanf("%d", &mat[i][j]);
  }
  counts = 0;
  for (int i = 1; i <= n; i++) counts += mat[i][i];
  counts %= 2;
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int a;
    scanf("%d", &a);
    if (a == 1 || a == 2) {
      int b;
      scanf("%d", &b);
      mat[b][b] = 1 - mat[b][b];
      counts = 1 - counts;
    } else
      printf("%d", counts);
  }
  printf("\n");
  return 0;
}
