import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

void main ()
{
	int n;
	while (scanf (" %d", &n) > 0)
	{
		bool s = false;
		foreach (i; 0..n)
		{
			foreach (j; 0..n)
			{
				int t;
				scanf (" %d", &t);
				if (i == j)
				{
					if (t)
					{
						s ^= true;
					}
				}
			}
		}

		int q;
		scanf (" %d", &q);
		string res;
		foreach (k; 0..q)
		{
			int t, i;
			scanf (" %d", &t);
			switch (t)
			{
				case 1:
				case 2:
					scanf (" %d", &i);
					s ^= true;
					break;
				case 3:
					res ~= s ? '1' : '0';
					break;
				default:
					assert (false);
			}
		}
		writeln (res);
	}
}
