#include <bits/stdc++.h>
using namespace std;
int a[1010][1010], b[1010][4], c[1010];
int n;
void conduct() {
  int i, j, q, cmd, sum;
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  for (sum = i = 0; i < n; ++i) sum += a[i][i];
  sum &= 1;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &cmd);
    if (cmd < 3) {
      scanf("%d", &i);
      sum = (sum + 2 * a[i][i] - 1) & 1;
    } else
      printf("%d", sum);
  }
  printf("\n");
}
int main() {
  while (scanf("%d", &n) != EOF) conduct();
  return 0;
}
