#include <bits/stdc++.h>
using namespace std;
;
struct _dbg {
  template <class T>
  _dbg& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  };
};
_dbg _d;
int a[1000], N, Q;
string r;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 0, _i = (N); i < _i; ++i)
    for (int j = 0, _j = (N); j < _j; ++j) {
      int x;
      cin >> x;
      if (i == j) a[i] = x;
    };
  auto s = 0;
  for (int i = 0, _i = (N); i < _i; ++i) s ^= a[i];
  cin >> Q;
  for (int i = 0, _i = (Q); i < _i; ++i) {
    int t;
    cin >> t;
    if (t < 3)
      cin >> t, s ^= 1;
    else if (t == 3)
      r += s + '0';
  };
  cout << r << '\n';
};
