#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  int t[1005][1005];
  int val = 0;
  cin >> n;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) cin >> t[i][j];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) val = (val + t[i][j] * t[j][i]) % 2;
  cin >> q;
  string ch = "";
  int a, b;
  int nb = 0;
  for (int i = 1; i <= q; i++) {
    cin >> a;
    if (a != 3) cin >> b;
    if (a != 3)
      nb++;
    else {
      if (nb % 2 == 0) {
        if (val == 1)
          ch += "1";
        else
          ch += "0";
      } else {
        if (val == 1)
          ch += "0";
        else
          ch += "1";
        val = !val;
      }
      nb = 0;
    }
  }
  cout << ch << '\n';
}
