#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::vector<std::vector<std::vector<T>>> make_3d_vector(long long z,
                                                        long long y,
                                                        long long x,
                                                        T value = T{}) {
  return std::vector<std::vector<std::vector<T>>>(
      z, std::vector<std::vector<T>>(y, std::vector<T>(x, value)));
}
template <typename T>
std::vector<std::vector<T>> make_2d_vector(long long z, long long y,
                                           T value = T{}) {
  return std::vector<std::vector<T>>(z, std::vector<T>(y, value));
}
template <typename T>
std::vector<T> make_1d_vector(long long z, T value = T{}) {
  return std::vector<T>(z, value);
}
void solve() {
  long long n;
  cin >> n;
  long long tot = 0;
  vector<vector<long long>> v(n, vector<long long>(n));
  map<long long, long long> row;
  map<long long, long long> col;
  long long total = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> v[i][j];
      if (i == j && v[i][j]) {
        total++;
      }
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    if (x == 1 || x == 2) {
      long long y;
      cin >> y;
      total++;
    } else if (x == 3) {
      cout << total % 2;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}
