#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
void dbg(const char* fmt, ...) {}
using namespace std;
const int N = 1100;
int a[N][N];
int p[N][2][2];
int row[N], col[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  int sum = 0;
  for (int i = 0; i < n; ++i) sum ^= a[i][i];
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x;
      scanf("%d", &x);
      sum ^= 1;
    } else if (t == 2) {
      int x;
      scanf("%d", &x);
      sum ^= 1;
    } else if (t == 3) {
      printf("%d", sum);
    } else
      throw 42;
  }
  return 0;
}
