#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001;
bool A[maxn][maxn];
int z11[maxn], z10[maxn], z01[maxn], z00[maxn];
int intersec[maxn];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> A[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j)
        intersec[i] = A[i][j];
      else if (A[i][j] == 1 && A[j][i] == 1)
        z11[i]++;
      else if (A[i][j] == 1 && A[j][i] == 0)
        z10[i]++;
      else if (A[i][j] == 0 && A[j][i] == 1)
        z01[i]++;
      else
        z00[i]++;
    }
  int current = 0;
  for (int i = 0; i < n; i++) current += (z11[i] % 2) + intersec[i];
  int q;
  cin >> q;
  string s;
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 3)
      s += '0' + (current % 2);
    else {
      int x;
      cin >> x;
      current++;
    }
  }
  cout << s << '\n';
  return 0;
}
