#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int	n;
	cin >> n;
	bitset<64>	bs;
	rep(i, n)
	{
		int	a;
		cin >> a;
		if (a >= 0 && a < 4)
		{
			int	b;
			cin >> b;
			if (a == 0) // test
				cout << bs.test(b) << endl;
			else if (a == 1) // set
				bs.set(b);
			else if (a == 2) // clear
				bs.reset(b);
			else // flip
				bs.flip(b);
		}
		else if (a == 4) // all
			cout << bs.all() << endl;
		else if (a == 5) // any
			cout << bs.any() << endl;
		else if (a == 6) // none
			cout << bs.none() << endl;
		else if (a == 7) // count
			cout << bs.count() << endl;
		else // val
			cout << bs.to_ullong() << endl;
	}
}

