#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const long long lINF = (1LL << 62) - 1;
const double dINF = 1e40;
const int MAXN = 1010;
int v[MAXN][MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (auto i = 0; i != n; i++)
    for (auto j = 0; j != n; j++) scanf("%d", &v[i][j]);
  int res = 0;
  for (auto i = 0; i != n; i++)
    for (auto j = 0; j != n; j++) res ^= (v[i][j] & v[j][i]);
  int q;
  scanf("%d", &q);
  while (q-- > 0) {
    int op;
    scanf("%d", &op);
    if (op == 3)
      putchar(res + '0');
    else {
      int p;
      scanf("%d", &p);
      res ^= 1;
    }
  }
  puts("");
  return 0;
}
