#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int temp;
  int sq = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &temp);
      if (i == j) {
        if (temp == 1) {
          sq++;
        }
      }
    }
  }
  if (sq % 2 == 0) {
    sq = 0;
  } else {
    sq = 1;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp);
    if (temp == 1) {
      scanf("%d", &temp);
      sq = 1 - sq;
    } else if (temp == 2) {
      scanf("%d", &temp);
      sq = 1 - sq;
    } else {
      printf("%d", sq);
    }
  }
  cout << endl;
  return 0;
}
