#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
const double eps = 1e-6;
int a[maxn][maxn];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int ans = 0;
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) scanf("%d", &a[i][j]);
      ans ^= a[i][i];
    }
    int m;
    scanf("%d", &m);
    while (m--) {
      int x;
      scanf("%d", &x);
      if (x == 3)
        printf("%d", ans);
      else {
        int y;
        scanf("%d", &y);
        y--;
        ans ^= a[y][y];
        a[y][y] = 1 - a[y][y];
        ans ^= a[y][y];
      }
    }
    printf("\n");
  }
  return 0;
}
