#include <bits/stdc++.h>
using namespace std;
void debug() {}
int const N = 1e3 + 9, OO = 1e9;
int main() {
  int n, q, type, a;
  char b;
  bool prd = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf(" %c", &b);
      if (j == i && b == '1') prd = !prd;
    }
  }
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &type);
    if (type != 3) scanf("%d", &a);
    if (type == 1 || type == 2)
      prd = !prd;
    else
      printf((prd) ? "1" : "0");
  }
}
