#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int b;
      scanf("%d", &b);
      if (i == j) s ^= b;
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int v;
    scanf("%d", &v);
    if (v == 3)
      cout << s;
    else {
      int i;
      scanf("%d", &i);
      s ^= 1;
    }
  }
  return 0;
}
