#include <bits/stdc++.h>
using namespace std;
long long int containsDigit(long long int number, long long int digit) {
  while (number != 0) {
    int curr_digit = number % 10;
    if (curr_digit == digit) return 1;
    number /= 10;
  }
  return 0;
}
long long int soltn(long long int x, long long int n) {
  if (x >= 0)
    return x % n;
  else
    return n + x % n;
}
long long int pd(long long int x, long long int y) {
  if (x % y == 0)
    return x / y;
  else
    return x / y + 1;
}
long long int coda(long long int n, long long int d) {
  long long int count = 0;
  while (n != 0) {
    if (n % 10 == d) count++;
    n /= 10;
  }
  return count;
}
long long int mdls(long long int x) { return max(x, -x); }
long long int pow1(long long int n, long long int p) {
  if (p == 0) return 1;
  long long int x = pow1(n, p / 2);
  x = (x * x) % 1000000007;
  if (p % 2 == 0)
    return x;
  else
    return (x * n) % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int t = 1;
  while (t--) {
    long long int n, m, j, k, l, i;
    cin >> n;
    long long int a[n][n];
    vector<long long int> R[n];
    vector<long long int> C[n];
    map<long long int, long long int> Mr;
    map<long long int, long long int> Mc;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        cin >> a[i][j];
        R[i].push_back(a[i][j]);
        Mr[i] += a[i][j];
      }
    }
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        C[i].push_back(a[j][i]);
        Mc[i] += a[j][i];
      }
    }
    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) ans += R[i][j] * C[i][j];
    }
    ans %= 2;
    long long int q;
    cin >> q;
    while (q--) {
      long long int N;
      cin >> N;
      if (N == 3)
        cout << mdls(ans % 2);
      else {
        cin >> k;
        if (a[k - 1][k - 1] == 1) {
          ans--;
          a[k - 1][k - 1] = 0;
        } else {
          ans++;
          a[k - 1][k - 1] = 1;
        }
      }
    }
    cout << "\n";
  }
  return 0;
}
