#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& out, pair<A, B>& p) {
  cout << "(" << p.first << "," << p.second << ") ";
}
template <typename A, typename B>
void printP(const pair<A, B>& p, const char* str = NULL) {
  if (str != NULL) cout << str << ":";
  cout << "(" << p.first << "," << p.second << ") ";
}
template <typename T>
void printT(const T* v, int n, const char* str = NULL) {
  if (str != NULL) cout << str << ": [";
  for (int i = 0; i < (n); ++i) {
    cout << v[i];
    if (i < n - 1) cout << " ";
  }
  cout << "]" << endl;
}
template <typename T>
void printV(const vector<T>& v, const char* str = NULL) {
  printT(&v[0], v.size(), str);
}
const int INF = INT_MAX - 1;
const long long LINF = LONG_LONG_MAX - 1;
const int MOD = 1000000007;
const int S_N = 300010;
const int S_K = 10;
int T[1001][1001];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) scanf("%d", &T[i][j]);
  int sum = 0;
  for (int i = 0; i < (n); ++i)
    for (int k = 0; k < (n); ++k) sum += T[i][k] * T[k][i];
  int q;
  scanf("%d", &q);
  string R;
  for (int i = 0; i < (q); ++i) {
    int c;
    scanf("%d", &c);
    if (c == 1 || c == 2) {
      int x;
      scanf("%d", &x);
      sum++;
    } else {
      R.push_back('0' + (sum % 2));
    }
  }
  printf("%s\n", R.c_str());
}
int main() {
  ios_base::sync_with_stdio(1);
  solve();
  return 0;
}
