#include <bits/stdc++.h>
using namespace std;
int A[1000];
int main() {
  int n, one = 0, a[1000][1000], E = 0, sum = 0, ts = 0;
  int q, rr, tt;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] + a[j][i] == 2) E++;
  if (E % 2 == 0)
    E = 0;
  else
    E = 1;
  scanf("%d", &q);
  for (int k = 0; k < q; k++) {
    scanf("%d", &tt);
    if (tt != 3) {
      scanf("%d", &rr);
      --rr;
    }
    if (tt == 1) E = abs(E - 1);
    if (tt == 2) E = abs(E - 1);
    if (tt == 3) cout << E;
  }
  printf("\n");
  return 0;
}
