#include <bits/stdc++.h>
using namespace std;
int n, q, ans, xs, type, junk;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &xs);
      if (i == j) ans ^= xs;
    }
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &type);
    if (type == 1 || type == 2) {
      scanf("%d", &junk);
      ans ^= 1;
    } else
      printf("%d", ans);
  }
  printf("\n");
  return 0;
}
