#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, z = 0;
  scanf("%d", &n);
  int arr[n][n];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) scanf("%d", &arr[i][j]);
  }
  for (int i = 0; i < n; ++i) {
    if (arr[i][i] == 1) ++z;
  }
  string ans = "";
  scanf("%d", &q);
  while (q--) {
    int type, k;
    scanf("%d", &type);
    if (type == 1 || type == 2) {
      scanf("%d", &k);
      --k;
      if (arr[k][k] == 1)
        --z;
      else
        ++z;
      arr[k][k] ^= 1;
    } else {
      int t = z % 2;
      ans += (t + '0');
    }
  }
  cout << ans;
  return 0;
}
