#include <bits/stdc++.h>
const long long INF = 10000000000000;
const long long mod = 1e9 + 7;
using namespace std;
void add(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
unsigned long long Pow(unsigned long long a, unsigned long long b) {
  if (b == 0) return 1;
  unsigned long long c = Pow(a, b / 2);
  if (b % 2) return c * c * a;
  return c * c;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  int n;
  cin >> n;
  vector<std::vector<int> > a(n, std::vector<int>(n));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> a[i][j];
    ans += a[i][i];
  }
  int q;
  cin >> q;
  int j;
  string s = "";
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 3) {
      if (ans % 2)
        s += '1';
      else
        s += '0';
    } else {
      cin >> j;
      j--;
      if (a[j][j] == 1)
        ans--;
      else
        ans++;
      a[j][j] = 1 - a[j][j];
    }
  }
  cout << s << endl;
  return 0;
}
