#include <stdio.h>
#include <stdint.h>
#define DIGIT 64

class Operation
{
    public:
    void Test(uint8_t state[], uint8_t num);
    void Set(uint8_t *state, uint8_t num);
    void Clear(uint8_t *state, uint8_t num);
    void Flip(uint8_t *state, uint8_t num);
    void All(uint8_t state[]);
    void Any(uint8_t state[]);
    void None(uint8_t state[]);
    void Count(uint8_t state[]);   
    void Val(uint8_t state[]);
};

void Operation::Test(uint8_t state[], uint8_t num)
{
    if(state[num] == 1)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
}

void Operation::Set(uint8_t *state, uint8_t num)
{
    state[num] = 1;
}

void Operation::Clear(uint8_t *state, uint8_t num)
{
    state[num] = 0;
}

void Operation::Flip(uint8_t *state, uint8_t num)
{
    if(state[num] == 1)
    {
        state[num] = 0;
    }
    else
    {
        state[num] = 1;
    }
}

void Operation::All(uint8_t state[])
{
    bool flag = true;
    
    for(int i = 0; i < DIGIT; i++)
    {
        if(state[i] == 0)
        {
            flag = false;
            break;
        }
    }
    
    if(flag == true)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
}

void Operation::Any(uint8_t state[])
{
    bool flag = false;
    
    for(int i = 0; i < DIGIT; i++)
    {
        if(state[i] == 1)
        {
            flag = true;
            break;
        }
    }
    
    if(flag == true)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
}

void Operation::None(uint8_t state[])
{    
    bool flag = true;
    
    for(int i = 0; i < DIGIT; i++)
    {
        if(state[i] == 1)
        {
            flag = false;
            break;
        }
    }
    
    if(flag == true)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
}

void Operation::Count(uint8_t state[])
{
    uint8_t Count = 0;
    
    for(int i = 0; i < DIGIT; i++)
    {
        if(state[i] == 1)
        {
            Count++;
        }
    }
    printf("%u\n", Count);
}

void Operation::Val(uint8_t state[])
{
    uint64_t stnum = 0;
    uint64_t base = 1;
    
    for(int i = 0; i < DIGIT; i++)
    {
        stnum = stnum + state[i] * base;
        base = base * 2;
    }
    printf("%lu\n", stnum);
}


int main(void)
{
    uint32_t q;
    uint8_t query;
    uint8_t num;
    uint8_t state[DIGIT] = {};
    
    Operation op;
    
    scanf("%u", &q);
    
    for(uint32_t i = 0; i < q; i++)
    {
        scanf("%hhu", &query);
        if(query < 4)
        {
            scanf("%hhu", &num);
        }
        
        switch(query)
        {
            case 0:
                op.Test(state, num);
                break;
            
            case 1:
                op.Set(state, num);
                break;
    
            case 2:
                op.Clear(state, num);
                break;
                
            case 3:
                op.Flip(state, num);
                break;
                
            case 4:
                op.All(state);
                break;
                
            case 5:
                op.Any(state);
                break;
                
            case 6:
                op.None(state);
                break;
                
            case 7:
                op.Count(state);
                break;
                
            case 8:
                op.Val(state);
                break;    
            
            default:
                break;
        }
    }         
    return 0;
}

