#include <bits/stdc++.h>
using namespace std;
int n, q;
int M[1000][1000];
int val;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &M[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      val += M[i][j] * M[j][i];
      val %= 2;
    }
  }
  scanf("%d", &q);
  for (int z = 0; z < q; ++z) {
    int op;
    scanf("%d", &op);
    if (op <= 2) {
      int idx;
      scanf("%d", &idx);
      val = 1 - val;
    } else {
      printf("%d", val);
    }
  }
  printf("\n");
}
