#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() {
  cin >> N;
  for (int i = 0, _i = (N); i < _i; ++i)
    for (int j = 0, _j = (N); j < _j; ++j) {
      int x;
      scanf("%d", &x);
      if (i == j) a[i] = x;
    };
  cin >> Q;
  for (int i = 0, _i = (Q); i < _i; ++i) {
    int t;
    scanf("%d", &t);
    if (t < 3) {
      int x;
      scanf("%d", &x);
      a[x - 1] ^= 1;
    };
    if (t == 3) {
      auto s = 0;
      for (int i = 0, _i = (N); i < _i; ++i) s ^= a[i];
      r += s + '0';
    };
  };
  cout << r << '\n';
};
