#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long n;
  cin >> n;
  long num, ans = 0;
  string s;
  for (long i = 1; i <= n; i++)
    for (long j = 1; j <= n; j++) {
      cin >> num;
      if (i == j) {
        ans += num;
        getline(cin, s, '\n');
        break;
      }
    }
  ans %= 2;
  long q;
  cin >> q;
  long query;
  while (q--) {
    cin >> query;
    if (3 == query)
      printf("%d", ans);
    else {
      cin >> num;
      ans = 1 - ans;
    }
  }
  return 0;
}
