#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-5;
int main() {
  int n;
  scanf("%d", &n);
  int matrix[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &matrix[i][j]);
  int score[n][4];
  int curbit[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) score[i][j] = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      score[i][matrix[i][j] * 2 + matrix[j][i]]++;
    }
    for (int j = 0; j < 4; j++) {
      score[i][j] %= 2;
    }
    curbit[i] = 3;
    ans += score[i][3];
    if (matrix[i][i] == 1) ans++;
  }
  int q;
  cin >> q;
  ans %= 2;
  string output = "";
  for (int i = 0; i < q; i++) {
    int op;
    scanf("%d", &op);
    if (op == 3) {
      output += char('0' + ans);
    } else if (op == 1) {
      int r;
      scanf("%d", &r);
      ans++;
    } else if (op == 2) {
      int r;
      scanf("%d", &r);
      ans++;
    }
    ans %= 2;
  }
  cout << output << endl;
  return 0;
}
