#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<pair<int, int>>;
void solve() {
  int n;
  cin >> n;
  int r = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      if (i == j) r += x;
    }
  }
  r %= 2;
  string res;
  int q;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    if (t == 3)
      res += to_string(r);
    else if (t == 1 || t == 2) {
      int waste;
      cin >> waste;
      r ^= 1;
    }
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  while (tc--) solve();
}
