#include <bits/stdc++.h>
using namespace std;
int mat[1001][1001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &mat[i][j]);
  int val = 0;
  for (int i = 0; i < n; i++) val = (val + mat[i][i]) % 2;
  int q, comm;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &comm);
    if (comm == 3)
      printf("%d", val);
    else {
      val = (val + 1) % 2;
      int tr;
      scanf("%d", &tr);
    }
  }
}
