#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18;
const long double eps = 1e-7;
const long double eps1 = 1e-10;
const int mod = (1e9 + 7);
const long long mod1 = 1e9 + 7;
const long long mod2 = 1e9 + 9;
const long long p1 = 29;
const long long p2 = 31;
const int ver1 = (62 * 62);
int ar[1010][1010];
pair<int, int> sum[1010];
int sc[1010];
int main() {
  int n;
  cin >> n;
  int scal = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &ar[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    scal += ar[i][i];
  }
  int m;
  cin >> m;
  for (; m; --m) {
    int q;
    scanf("%d", &q);
    if (q == 1 || q == 2) {
      int i;
      scanf("%d", &i);
      --i;
      scal -= ar[i][i];
      ar[i][i] ^= 1;
      scal += ar[i][i];
    } else {
      printf("%d", scal % 2);
    }
  }
  return 0;
}
