#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, cho, i, j, q;
  cin >> n;
  int ar[n + 1];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &cho);
      if (i == j) {
        ar[i] = cho;
        sum += ar[i];
      }
    }
  }
  scanf("%d", &q);
  int res[q], top = -1;
  for (i = 0; i < q; i++) {
    scanf("%d", &cho);
    if (cho < 3) {
      scanf("%d", &cho);
      if (ar[cho] == 1)
        sum -= 1;
      else
        sum += 1;
      ar[cho] = 1 - ar[cho];
    } else
      res[++top] = sum % 2;
  }
  for (i = 0; i <= top; i++) printf("%d", res[i]);
}
