#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int e;
      cin >> e;
      if (i == j) {
        sum += e;
        sum %= 2;
      }
    }
  }
  int q;
  cin >> q;
  int ans[1000000];
  int ansPos = 0;
  for (int i = 0; i < q; ++i) {
    int w;
    cin >> w;
    if (w == 1 || w == 2) {
      int e;
      cin >> e;
      sum += 1;
      sum %= 2;
    } else {
      ans[ansPos] = sum;
      ++ansPos;
    }
  }
  for (int i = 0; i < ansPos; ++i) {
    cout << ans[i];
  }
  cout << '\n';
}
