#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<vector<bool> > grid(n, vector<bool>(n, false));
  int tmp;
  for (int i = int(0); i <= int(n - 1); i++)
    for (int j = int(0); j <= int(n - 1); j++) {
      scanf("%d", &tmp);
      grid[i][j] = tmp;
    }
  int q;
  scanf("%d", &q);
  int ans = 0;
  for (int i = int(0); i <= int(n - 1); i++) ans ^= grid[i][i];
  for (int p = int(1); p <= int(q); p++) {
    int type, v;
    scanf("%d", &type);
    switch (type) {
      case 1:
      case 2:
        scanf("%d", &v);
        v--;
        grid[v][v] = 1 - grid[v][v];
        ans = !ans;
        break;
      case 3:
        printf("%d", ans);
        break;
    }
  }
  printf("\n");
  return 0;
}
