#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> MAT(n);
  int total = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int num;
      cin >> num;
      if (i == j) {
        MAT[i] = num;
        if (MAT[i] == 1) total++;
      }
    }
  }
  string res;
  int q;
  cin >> q;
  while (q--) {
    int type, ind;
    cin >> type;
    switch (type) {
      case 1:
      case 2:
        cin >> ind;
        ind--;
        if (MAT[ind] == 1) {
          MAT[ind] = 0;
          total--;
        } else {
          MAT[ind] = 1;
          total++;
        }
        break;
      case 3:
        printf("%d", total % 2);
        break;
    }
  }
}
