#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e6 + 7;
const int Max = 1e3 + 7;
int a[Max][Max], n, m, ted, k, row[Max];
char ans[Maxn];
void Fill() {
  for (int i = 1; i <= n; i++) row[i] = a[i][i], ted += a[i][i];
}
void Solve(int t, int x) {
  if (t < 3)
    row[x] ^= 1, ted += (row[x] * 2) - 1;
  else
    ans[k++] += ('0' + (ted % 2));
}
void get() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  Fill();
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int t, x;
    scanf("%d", &t);
    if (t < 3) scanf("%d", &x);
    Solve(t, x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  get();
  puts(ans);
}
