#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(5e5) + 10;
const int m = (int)(1e6);
int n;
int cur;
int a[1050][1050];
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++) {
      if (a[i][j] + a[j][i] == 2) {
        cur ^= 1;
      }
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int tp;
    scanf("%d", &tp);
    if (tp < 3) {
      int ind;
      scanf("%d", &ind);
      cur ^= 1;
    } else {
      printf("%d", (cur & 1));
    }
  }
  return 0;
}
