#include <bits/stdc++.h>
const int N = 1000 + 10;
int a[N][N];
int main() {
  int n, qn, q1, q2;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  int ans = 0;
  for (int i = 0; i < n; i++) ans += a[i][i];
  scanf("%d", &qn);
  while (qn--) {
    scanf("%d", &q1);
    if (q1 == 3) {
      ans &= 1;
      printf("%d", ans);
    } else {
      scanf("%d", &q2);
      ++ans;
    }
  }
  return 0;
}
