#include <bits/stdc++.h>
using namespace std;
bool mat[1000][1000];
int sumrow[1000], sumcol[1000], sumboth[1000];
int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (long long i = 0; i < (int)N; i++)
    for (long long j = 0; j < (int)N; j++) scanf("%d", mat[i] + j);
  for (long long i = 0; i < (int)N; i++)
    for (long long j = 0; j < (int)N; j++) sumrow[i] += mat[i][j];
  for (long long i = 0; i < (int)N; i++)
    for (long long j = 0; j < (int)N; j++) sumcol[i] += mat[j][i];
  for (long long i = 0; i < (int)N; i++)
    for (long long j = 0; j < (int)N; j++) sumboth[i] += mat[i][j] * mat[j][i];
  for (long long i = 0; i < (int)N; i++) sum += sumboth[i];
  sum %= 2;
  int Q;
  cin >> Q;
  for (long long i = 0; i < (int)Q; i++) {
    int type, index;
    scanf("%d", &type);
    if (type == 3)
      cout << sum;
    else {
      scanf("%d", &index);
      if (type == 1) {
        sum++;
        sum %= 2;
      }
      if (type == 2) {
        sum++;
        sum %= 2;
      }
    }
  }
  return 0;
}
