#include <bits/stdc++.h>
using namespace std;
int arr[1001][1001];
vector<int> ans;
int main() {
  int n = 0, q = 0, total = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &arr[i][j]);
      total += (i == j ? arr[i][j] : 0);
    }
  scanf("%d", &q);
  for (int z = 0; z < q; z++) {
    int x = 0, y = 0;
    scanf("%d", &x);
    if (x == 1) {
      scanf("%d", &y);
      total -= arr[y][y];
      arr[y][y] ^= 1;
      total += arr[y][y];
    } else if (x == 2) {
      scanf("%d", &y);
      total -= arr[y][y];
      arr[y][y] ^= 1;
      total += arr[y][y];
    } else
      ans.push_back(total % 2);
  }
  for (int i = 0; i < (int)ans.size(); i++) printf("%d", ans[i]);
  return 0;
}
