#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 9;
int mat[MAXN][MAXN];
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &mat[i][j]);
    }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans ^= mat[i][i];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int type, idx;
    scanf("%d", &type);
    if (type == 1 || type == 2) {
      scanf("%d", &idx);
      ans = 1 - ans;
    } else
      printf("%d", ans);
  }
  return 0;
}
