#include <bits/stdc++.h>
int a[1005][1005];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
    int sum = 0;
    for (int k = 1; k <= n; k++)
      for (int i = 1; i <= n; i++) sum = (sum + a[k][i] * a[i][k]) % 2;
    int q;
    scanf("%d", &q);
    while (q--) {
      int x, y;
      scanf("%d", &x);
      if (x < 3) {
        sum ^= 1;
        scanf("%d", &y);
      } else
        printf("%d", sum);
    }
    printf("\n");
  }
  return 0;
}
