#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int f[1001];
bool l[1001], r[1001];
int n, m;
void Solve() {
  int i, j, k;
  cin >> n;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  int ans = 0;
  for (i = 1; i <= n; ++i) f[i] = a[i][i], ans += a[i][i];
  cin >> k;
  while (k--) {
    scanf("%d", &j);
    if (j <= 2) {
      scanf("%d", &i);
      ans -= f[i];
      f[i] = 1 - f[i];
      ans += f[i];
    } else
      printf("%d", ans % 2);
  }
  puts("");
}
int main() {
  int test;
  Solve();
  cin >> n;
  return 0;
}
