#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  long n, q;
  cin >> n;
  long ans = 0;
  long b[1000][4] = {};
  long cen[1000] = {};
  long now[1000] = {};
  vector<vector<long> > v(n, vector<long>(n, 0));
  for (long long f = (long long)0; f <= (long long)n - 1; ++f) {
    for (long long ff = (long long)0; ff <= (long long)n - 1; ++ff) {
      cin >> v[f][ff];
    }
  }
  cin >> q;
  for (long long f = (long long)0; f <= (long long)n - 1; ++f) {
    for (long long ff = (long long)0; ff <= (long long)n - 1; ++ff) {
      if (f == ff) continue;
      b[f][0] += v[f][ff] * v[ff][f];
      b[f][0] += v[f][ff] * v[ff][f];
      b[f][0] %= 2;
    }
    for (long long ff = (long long)0; ff <= (long long)n - 1; ++ff) {
      if (f == ff) continue;
      b[f][1] += v[f][ff] * (v[ff][f] ^ 1);
      b[f][1] += v[f][ff] * (v[ff][f] ^ 1);
      b[f][1] %= 2;
    }
    for (long long ff = (long long)0; ff <= (long long)n - 1; ++ff) {
      if (f == ff) continue;
      b[f][2] += (v[f][ff] ^ 1) * v[ff][f];
      b[f][2] += (v[f][ff] ^ 1) * v[ff][f];
      b[f][2] %= 2;
    }
    for (long long ff = (long long)0; ff <= (long long)n - 1; ++ff) {
      if (f == ff) continue;
      b[f][3] += (v[f][ff] ^ 1) * (v[ff][f] ^ 1);
      b[f][3] += (v[f][ff] ^ 1) * (v[ff][f] ^ 1);
      b[f][3] %= 2;
    }
  }
  for (long long f = (long long)0; f <= (long long)n - 1; ++f) {
    ans += b[f][0];
    ans += v[f][f];
    ans %= 2;
  }
  for (long long fq = (long long)1; fq <= (long long)q; ++fq) {
    long type;
    cin >> type;
    if (type != 3) {
      long i;
      cin >> i;
      i--;
      if (type == 1) {
        long tmp = now[i];
        now[i] = now[i] ^ 2;
        ans -= b[i][tmp];
        ans += b[i][now[i]];
        ans += 1;
        ans %= 2;
      }
      if (type == 2) {
        long tmp = now[i];
        now[i] = now[i] ^ 1;
        ans -= b[i][tmp];
        ans += b[i][now[i]];
        ans += 1;
        ans %= 2;
      }
    } else {
      cout << ans;
    }
  }
  return 0;
}
