#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 10);
int n;
int a[MAXN][MAXN];
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
}
int q, ans;
void solve() {
  ans = 0;
  for (int i = 1; i <= n; i++) ans = (ans + a[i][i] * a[i][i]) % 2;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int type;
    scanf("%d", &type);
    if (type == 1 || type == 2) {
      int x;
      scanf("%d", &x);
      ans = (ans - a[x][x] + (a[x][x]) ^ 1 + 2) % 2;
      a[x][x] ^= 1;
    }
    if (type == 3) printf("%d", ans);
  }
  printf("\n");
}
int main() {
  read();
  solve();
  return 0;
}
