#include <bits/stdc++.h>
using namespace std;
int a[1005][1005], b[1005][1005];
char ans[1000005];
int main() {
  int n, q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  int sum1 = 0;
  for (int i = 0; i < n; i++) {
    int sum2 = 0;
    for (int j = 0; j < n; j++) sum2 = (sum2 + a[i][j] * a[j][i]) % 2;
    sum1 = (sum1 + sum2) % 2;
  }
  scanf("%d", &q);
  int la = 0;
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 3)
      ans[la++] = sum1 + '0';
    else if (op == 1) {
      int tmp;
      scanf("%d", &tmp);
      sum1 = 1 - sum1;
    } else {
      int tmp;
      scanf("%d", &tmp);
      sum1 = 1 - sum1;
    }
  }
  ans[la] = '\0';
  puts(ans);
  return 0;
}
