#include <bits/stdc++.h>
using namespace std;
int a[1005][1005], n;
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &a[i][j]);
      if (i == j) ans ^= a[i][j];
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int cmd, x;
    scanf("%d", &cmd);
    if (cmd == 1 || cmd == 2) {
      scanf("%d", &x);
      ans ^= 1;
    } else {
      printf("%d", ans);
    }
  }
}
