#include <bits/stdc++.h>
using namespace std;
int N, Q;
int ans = 0;
int main() {
  scanf("%d", &N);
  for (int i = 0, tmp; i < N; ++i)
    for (int j = 0; j < N; ++j) {
      scanf("%d", &tmp);
      if (i == j) ans ^= tmp;
    }
  scanf("%d", &Q);
  for (int i = 0; i < Q; ++i) {
    int op, pos;
    scanf("%d", &op);
    switch (op) {
      case 3:
        printf("%d", ans);
        break;
      case 2:
      case 1:
        scanf("%d", &pos), --pos;
        ans ^= 1;
    }
  }
  puts("");
  return 0;
}
