#include <bits/stdc++.h>
using namespace std;
inline void read_string_to_vector(vector<string> &vec) {
  string str;
  getline(cin, str);
  vec.push_back(str);
}
template <typename T>
inline void read_digit_to_vector(vector<T> &vec) {
  T t;
  cin >> t;
  vec.push_back(t);
}
long long n;
long long a[1004][1004];
long long mLine[1004][2];
long long mCollumn[1004][2];
bool mLineState[1004];
bool mCollumnState[1004];
long long mAnsw;
long long q;
int main() {
  scanf("%lld", &n);
  for (register long long i = 0; i < n; ++i)
    for (register long long j = 0; j < n; ++j) scanf("%lld", &a[i][j]);
  for (register long long i = 0; i < n; ++i)
    for (register long long j = 0; j < n; ++j) {
      mLine[i][0] += (a[i][j] * a[j][i]),
          mLine[i][1] += ((1 - a[i][j]) * a[j][i]);
    }
  for (register long long i = 0; i < n; ++i) mAnsw += mLine[i][0];
  for (register long long i = 0; i < n; ++i)
    for (register long long j = 0; j < n; ++j) {
      mCollumn[i][0] += (a[j][i] * a[i][j]);
      mCollumn[i][1] += ((1 - a[j][i]) * a[i][j]);
    }
  scanf("%lld", &q);
  while (q--) {
    long long type;
    scanf("%lld", &type);
    if (type == 1) {
      long long c;
      scanf("%lld", &c);
      --c;
      mLineState[c] = !mLineState[c];
      if (mLineState[c])
        mAnsw += -2 * mLine[c][0] + 2 * mLine[c][1] + a[c][c] * a[c][c] +
                 (1 - a[c][c]) * (1 - a[c][c]);
      else
        mAnsw += -2 * mLine[c][1] + 2 * mLine[c][0] + a[c][c] * a[c][c] +
                 (1 - a[c][c]) * (1 - a[c][c]);
    } else if (type == 2) {
      long long c;
      scanf("%lld", &c);
      --c;
      mCollumnState[c] = !mCollumnState[c];
      if (mCollumnState[c])
        mAnsw += -2 * mCollumn[c][0] + 2 * mCollumn[c][1] + a[c][c] * a[c][c] +
                 (1 - a[c][c]) * (1 - a[c][c]);
      else
        mAnsw += -2 * mCollumn[c][1] + 2 * mCollumn[c][0] + a[c][c] * a[c][c] +
                 (1 - a[c][c]) * (1 - a[c][c]);
    } else
      printf("%lld", ((mAnsw % 2LL) + 2LL) % 2LL);
  }
  putc('\n', stdout);
  return 0;
}
