#include<iostream>
#include<bitset>

using namespace std;

int main()
{
    bitset<64> bit;
    int q;
    cin>>q;
    while(q--)
    {
        int op,i;
        cin>>op;
        switch(op)
        {
        case 0:
            {
                cin>>i;
                cout<<bit.test(i)<<endl;
            }
            break;
        case 1:
            {
                cin>>i;
                bit.set(i);
            }
            break;
        case 2:
            {
                cin>>i;
                bit.reset(i);
            }
            break;
        case 3:
            {
                cin>>i;
                bit.flip(i);
            }
            break;
        case 4:
            {
                cout<<bit.all()<<endl;
            }
            break;
        case 5:
            {
                cout<<bit.any()<<endl;
            }
            break;
        case 6:
            {
                cout<<bit.none()<<endl;
            }
            break;
        case 7:
            {
                cout<<bit.count()<<endl;
            }
            break;
        case 8:
            {
                cout<<bit.to_ullong()<<endl;
            }
            break;
        }
    }
    return 0;
}

