#include <bits/stdc++.h>
using namespace std;
int a[1050][1050];
int main() {
  ios_base::sync_with_stdio(false);
  int n, f = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        f += a[i][j];
        f %= 2;
      } else {
        f += a[i][j] * a[j][i] * 2;
        f %= 2;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    if (x == 3) printf("%d", f);
    if (x == 2 || x == 1) {
      int y;
      scanf("%d", &y);
      f += 1;
      f %= 2;
    }
  }
}
