#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
int n, a[1001][1001];
int get_sum() {
  int ret = 0;
  for (int i = 0; i < n; i++) ret += a[i][i];
  return ret % 2;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  int q, sum = get_sum();
  scanf("%d", &q);
  while (q--) {
    int query, idx;
    scanf("%d", &query);
    if (query == 3) {
      printf("%d", sum);
    } else {
      scanf("%d", &idx), idx--;
      sum -= a[idx][idx];
      sum += 2;
      sum %= 2;
      a[idx][idx] = 1 - a[idx][idx];
      sum += a[idx][idx];
      sum %= 2;
    }
  }
  return 0;
}
