#include <bits/stdc++.h>
int main() {
  int i, j, n, q, k, m, s, sum;
  sum = 0;
  scanf("%d ", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      scanf("%d", &s);
      if (i == j) sum += s;
    }
  sum %= 2;
  scanf("%d ", &q);
  for (k = 0; k < q; k++) {
    scanf("%d ", &m);
    if (m == 3)
      printf("%d", sum % 2);
    else {
      scanf("%d ", &s);
      sum ^= 1;
    }
  }
}
