#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int main() {
  int n;
  scanf("%d", &n);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) scanf("%d", &a[i][j]);
  int result = 0;
  for (long long i = 0; i < n; i++) result ^= a[i][i];
  int q;
  scanf("%d", &q);
  for (long long i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (t < 3) {
      scanf("%d", &t);
      result ^= 1;
    } else {
      printf("%d", result);
    }
  }
  printf("\n");
  return 0;
}
