#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	bitset<64> b(0);
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		if(op <= 3){
			int i;
			cin >> i;
			if(op == 0)
				cout << b[i] << '\n';
			else if(op == 1)
				b[i] = 1;
			else if(op == 2)
				b[i] = 0;
			else
				b[i] = 1 - b[i];
		}else if(op == 4){
			bool ok = true;
			for(int i = 0; i < 64; i++)ok &= b[i];
			cout << ok << '\n';
		}else if(op == 5){
			bool ok = false;
			for(int i = 0; i < 64; i++)ok |= b[i];
			cout << ok << '\n';
		}else if(op == 6){
			bool ok = false;
			for(int i = 0; i < 64; i++)ok |= b[i];
			cout << !ok << '\n';
		}else if(op == 7){
			int ans = 0;
			for(int i = 0; i < 64; i++)if(b[i])ans++;
			cout << ans << '\n';
		}else{
			cout << b.to_ulong() << '\n';
		}
	}	
    return 0;
}

