#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char p[1000005];
int main() {
  while (~scanf("%d", &n)) {
    int x, y, ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        scanf("%d", &x);
        if (i == j) ans ^= x;
      }
    scanf("%d", &m);
    k = 0;
    memset(p, 0, sizeof(p));
    while (m--) {
      scanf("%d", &x);
      if (x == 3)
        p[k++] = ans + '0';
      else {
        scanf("%d", &y);
        ans ^= 1;
      }
    }
    printf("%s\n", p);
  }
  return 0;
}
