import sys
n = int(sys.stdin.readline())
S = 0
for i in range(n):
cmd = sys.stdin.readline().split()
if cmd[0] =='all':
S = (1 << 20) -1
elif cmd[0] == 'empty':
S = 0
else:
op = cmd[0]
x = int(cmd[1])-1
if op == 'add':
S |= (1 << x)
elif op == 'remove':
S &= ~(1 << x)
elif op =='check':
if S & (1 << x) == 0:
print(0)
else: print(1)
elif op == 'toggle':
S ^= (1<<x)