#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int mp[maxn][maxn];
int n;
int m;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) scanf("%d", &mp[i][j]);
    unsigned int sum = 0;
    for (int i = 0; i < n; i++) {
      unsigned int t = 0;
      for (int j = 0; j < n; j++) {
        t ^= (mp[i][j] & mp[j][i]);
      }
      sum ^= t;
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      int t;
      scanf("%d", &t);
      if (t == 3)
        printf("%d", sum);
      else {
        scanf("%d", &t);
        sum = !sum;
      }
    }
    printf("\n");
  }
  return 0;
}
