#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int c = 0;
  int a[1111][1111];
  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++)
    for (int j = 0; j < n; j++) {
      c += a[i][j] * a[j][i];
      c = c % 2;
    }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x;
    scanf("%d", &x);
    if (x == 3) {
      printf("%d", c);
    }
    if (x == 2) {
      int kom;
      scanf("%d", &kom);
      c = 1 - c;
    }
    if (x == 1) {
      int kom;
      scanf("%d", &kom);
      c = 1 - c;
    }
  }
}
