#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int sum = 0;
  vector<int> Q(n, 0);
  vector<vector<int> > MAT(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> MAT[i][j];
      if (i == j) sum += MAT[i][j], Q[i] = MAT[i][j];
    }
  }
  int q;
  cin >> q;
  string res;
  while (q-- > 0) {
    int choice, x;
    cin >> choice;
    if (choice == 2 || choice == 1) {
      cin >> x;
      x--;
      sum -= Q[x];
      Q[x] ^= 1;
      sum += Q[x];
    } else {
      char c = sum % 2 + '0';
      res.push_back(c);
    }
  }
  cout << res << '\n';
  return 0;
}
