#include <bits/stdc++.h>
using namespace std;
int a[1200][1200];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) res ^= int(a[i][j] == 1 && a[j][i] == 1);
  int query;
  cin >> query;
  for (int q = 0; q < query; q++) {
    int option, ind;
    cin >> option;
    if (option == 3)
      cout << res;
    else {
      cin >> ind;
      res ^= 1;
    }
  }
  return 0;
}
