#include <bits/stdc++.h>
using namespace std;
int n, q, ans, t, i, j, f1[1001], f2[1001], a[1001][1001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans += (a[i][j] & a[j][i]);
  ans %= 2;
  scanf("%d", &q);
  for (int k = 1; k <= q; k++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &i);
      ans ^= 1;
    }
    if (t == 2) {
      scanf("%d", &j);
      ans ^= 1;
    }
    if (t == 3) {
      printf("%d", ans % 2);
    }
  }
}
