#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int m[1010][1010];
int product[1010];
int sum;
int main(int argc, const char* argv[]) {
  int n;
  vector<int> s;
  scanf(" %d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int a;
      scanf(" %d", &a);
      m[i][j] = a;
    }
  }
  sum = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    for (int j = 0; j < n; j++) {
      a += m[i][j] * m[j][i];
    }
    product[i] = a % 2;
    sum += product[i];
  }
  sum %= 2;
  int queries;
  scanf(" %d", &queries);
  for (int p = 0; p < queries; p++) {
    int c;
    scanf(" %d", &c);
    if (c == 1) {
      int d;
      scanf(" %d", &d);
      d--;
      sum += 1;
      sum %= 2;
    } else if (c == 2) {
      int d;
      scanf(" %d", &d);
      sum += 1;
      sum %= 2;
    } else if (c == 3) {
      s.push_back(sum);
    }
  }
  long long l = s.size();
  for (int i = 0; i < l; i++) {
    printf("%d", s[i]);
  }
  printf("\n");
  return 0;
}
