#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n{}, q{};
  cin >> n;
  vector<vector<long long int>> a(n, vector<long long int>(n, 0));
  vector<long long int> x{};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a.at(i).at(j);
    }
  }
  long long int ans{};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans = ((ans % 2) + (a.at(i).at(j) * a.at(j).at(i)) % 2) % 2;
    }
  }
  long long int num{}, row{}, column{}, count{};
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> num;
    if (num == 1) {
      cin >> row;
      count++;
    } else if (num == 2) {
      cin >> column;
      count++;
    } else if (num == 3) {
      if (count % 2 == 0) {
        x.push_back(ans);
      } else {
        ans = 1 - ans;
        x.push_back(ans);
      }
      count = 0;
    }
  }
  for (int i = 0; i < x.size(); i++) {
    cout << x.at(i);
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
