#include <bits/stdc++.h>
using namespace std;
int x[1010][1010];
int main() {
  int n, type, q, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      scanf("%d", x[i] + j);
      if (i == j) ans ^= x[i][j];
    }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d", &type);
    int p;
    if (type == 1) scanf("%d", &p), ans ^= 1;
    if (type == 2) scanf("%d", &p), ans ^= 1;
    if (type == 3) printf("%d", ans);
  }
}
