#include <bits/stdc++.h>
using namespace std;
int n, q, sum, a[1111][1111], mark1[1111], mark2[1111], val[1111][4];
inline int f(int i) { return val[i][0] ^ mark1[i] ^ mark2[i]; }
int main() {
  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++) {
      val[i][0] ^= a[i][j] * a[j][i];
      val[i][1] ^= a[i][j] * (!a[j][i]);
      val[i][2] ^= (!a[i][j]) * a[j][i];
      val[i][3] ^= (!a[i][j]) * (!a[j][i]);
    }
  for (int i = 0; i < n; i++) sum ^= f(i);
  scanf("%d", &q);
  for (int x, y, i = 0; i < q; i++) {
    scanf("%d", &x);
    if (x == 1) {
      scanf("%d", &y);
      y--;
      sum ^= f(y);
      mark1[y] = !mark1[y];
      sum ^= f(y);
    }
    if (x == 2) {
      scanf("%d", &y);
      y--;
      sum ^= f(y);
      mark2[y] = !mark2[y];
      sum ^= f(y);
    }
    if (x == 3) printf("%d", sum);
  }
  printf("\n");
}
