#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &arr[i][j]);
  int q;
  scanf("%d", &q);
  int res = 0;
  for (int k = 0; k < n; k++) {
    res += arr[k][k];
    res %= 2;
  }
  for (int p = 0; p < q; p++) {
    int t;
    scanf("%d", &t);
    switch (t) {
      case 1: {
        int k;
        scanf("%d", &k);
        res = 1 - res;
      } break;
      case 2: {
        int k;
        scanf("%d", &k);
        k--;
        res = 1 - res;
      } break;
      case 3: {
        printf("%d", res);
      } break;
    }
  }
  return 0;
}
