#include <bits/stdc++.h>
double eps = 1e-9;
using namespace std;
int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int a;
      scanf("%d", &a);
      ;
      if (i == j) {
        count += a;
      }
    }
  }
  count = count % 2;
  int q;
  cin >> q;
  while (q--) {
    int b;
    scanf("%d", &b);
    ;
    if (b == 3) {
      cout << count;
    } else if (b == 2) {
      int c;
      scanf("%d", &c);
      ;
      count = count ^ 1;
    } else {
      int c;
      scanf("%d", &c);
      ;
      count = count ^ 1;
    }
  }
  return 0;
}
