#include <bits/stdc++.h>
using namespace std;
int n, a[1200][1200];
int q, ans = 0;
int x, num;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++)
    if (a[i][i]) ans++;
  ans %= 2;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &x);
    if (x == 3)
      printf("%d", ans);
    else {
      scanf("%d", &num);
      {
        a[num][num] = 1 - a[num][num];
        if (a[num][num])
          ans = (ans + 1) % 2;
        else
          ans = (ans - 1) % 2;
        ans = abs(ans);
      }
    }
  }
  printf("\n");
  return 0;
}
