#include <bits/stdc++.h>
using namespace std;
int m, t, a[1002][1002], n, q, ans;
int main(int argc, const char* argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) ans ^= (a[i][j] & a[j][i]);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &t);
    if (t == 1 || t == 2) {
      scanf("%d", &m);
      ans ^= 1;
    } else
      printf("%d", ans);
  }
  printf("\n");
  return 0;
}
