#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
class Reader {
 public:
  Reader(FILE *_stream, const int _size = (1 << 16))
      : size(_size), pointer(0), buffer(new char[_size]), stream(_stream) {
    assert(fread(buffer, 1, size, stream) != 0);
  }
  template <class IntType>
  IntType NextInt() {
    IntType value = 0;
    bool negative = false;
    while ((Current() < '0' || Current() > '9') && Current() != '-')
      NextPosition();
    if (Current() == '-') {
      negative = true;
      NextPosition();
    }
    while (Current() >= '0' && Current() <= '9') {
      value = value * 10 + Current() - '0';
      NextPosition();
    }
    if (negative) value = -value;
    return value;
  }
  Reader &operator>>(short &value) {
    value = NextInt<short>();
    return *this;
  }
  Reader &operator>>(int &value) {
    value = NextInt<int>();
    return *this;
  }
  Reader &operator>>(long long &value) {
    value = NextInt<long long>();
    return *this;
  }

 private:
  int size, pointer;
  char *buffer;
  FILE *stream;
  char Current() const { return buffer[pointer]; }
  void NextPosition() {
    if (++pointer == size) {
      assert(fread(buffer, 1, size, stream) != 0);
      pointer = 0;
    }
  }
};
int main() {
  Reader in = Reader(stdin);
  int n, sum = 0;
  string answers = "";
  in >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int value;
      in >> value;
      if (i == j) sum = (sum + value) % 2;
    }
  }
  int q;
  in >> q;
  for (; q > 0; --q) {
    int type;
    in >> type;
    if (type == 1 || type == 2) {
      int index;
      in >> index;
      sum = 1 - sum;
    } else if (type == 3) {
      if (sum == 0)
        answers += "0";
      else
        answers += "1";
    }
  }
  printf("%s\n", answers.c_str());
  return 0;
}
