#include <bits/stdc++.h>
using namespace std;
int m[1010][1010];
int main() {
  int n, q;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        scanf("%d", &m[i][j]);
      }
    }
    int ans = 0, sum = 0;
    for (int i = 1; i <= n; i++) {
      sum = 0;
      for (int j = 1; j <= n; j++) {
        sum += m[i][j] * m[j][i];
      }
      if (sum & 1) ans += 1;
    }
    if (ans & 1)
      ans = 1;
    else
      ans = 0;
    scanf("%d", &q);
    int q1, q2, order = 0;
    for (int i = 0; i < q; i++) {
      scanf("%d", &q1);
      if (q1 == 1) {
        scanf("%d", &q2);
        order++;
      }
      if (q1 == 2) {
        scanf("%d", &q2);
        order++;
      }
      if (q1 == 3) {
        if (order & 1) {
          ans = ans ^ 1;
        }
        printf("%d", ans);
        order = 0;
      }
    }
    puts("");
  }
  return 0;
}
