#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, q;
  scanf("%d", &n);
  int ans = 0, x;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &x);
      if (i == j) ans += x;
      ans %= 2;
    }
  }
  scanf("%d", &q);
  int op;
  string s = "";
  while (q--) {
    scanf("%d", &op);
    if (op <= 2)
      scanf("%d", &x), ans = 1 - ans;
    else
      s += char(ans + '0');
  }
  cout << s << endl;
  return 0;
}
