#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 7;
int n;
int A[MAXN][MAXN];
int scal = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      scanf("%d", &A[i][j]);
      if (i == j) scal = (scal + A[i][j]) % 2;
    }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 3) printf("%d", scal);
    if (t == 1) {
      int x;
      scanf("%d", &x);
      --x;
      scal = (scal + 1) % 2;
      A[x][x] = 1 - A[x][x];
    }
    if (t == 2) {
      int x;
      scanf("%d", &x);
      --x;
      scal = (scal + 1) % 2;
      A[x][x] = 1 - A[x][x];
    }
  }
  return 0;
}
