#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n));
  vector<int> b(n);
  int s = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
      if (i == j) {
        b[i] = a[i][j];
        s += b[i];
      }
    }
  int q;
  cin >> q;
  while (q--) {
    int k;
    scanf("%d", &k);
    if (k == 3) {
      printf("%d", s % 2);
    } else {
      cin >> k;
      s++;
    }
  }
}
