#include <bits/stdc++.h>
using namespace std;
int n, q;
int main() {
  int res = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (i == j) res = (res + x) % 2;
    }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int t;
    scanf("%d", &t);
    if (t == 3)
      printf("%d", res);
    else {
      int x;
      scanf("%d", &x);
      res = 1 - res;
    }
  }
}
