#include <bits/stdc++.h>
using namespace std;
int n, dp, q, c, b;
string ans = "";
void update(int &x) {
  if (x == 0)
    x = 1;
  else
    x = 0;
}
int main() {
  scanf("%d", &n);
  int a[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  }
  for (int i = 0; i < n; i++) dp = (dp + a[i][i]) % 2;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &b);
    if (b == 3) {
      printf("%d", dp);
    } else {
      scanf("%d", &c);
      update(dp);
    }
  }
  return 0;
}
