#include <bits/stdc++.h>
using namespace std;
long long n, m, k, t, a, b, c, d, e, f, x, y, z, sol = 0, ans = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  sol = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a;
      if (i == j) {
        if (a) sol++;
      }
    }
  }
  sol %= 2;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x;
    if (x == 3)
      cout << sol;
    else if (x == 2 || x == 1) {
      cin >> y;
      sol = (sol + 1) % 2;
    }
  }
  cout << "\n";
  return 0;
}
