https://www.acmicpc.net/problem/11723
import sys
input = sys.stdin.readline
num = int(input())
s = set()
zero = []
twenty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
for _ in range(num):
temp = list(input().split())
calc = temp[0]
if len(temp) != 1:
temp[1] = int(temp[1])
if calc == 'add':
s.add(temp[1])
elif calc == 'remove':
if temp[1] in s:
s.remove(temp[1])
elif calc == 'toggle':
if temp[1] in s:
s.remove(temp[1])
else:
s.add(temp[1])
elif calc == 'check':
if temp[1] in s:
print(1)
else:
print(0)
elif calc == 'all':
s = set(twenty)
elif calc == 'empty':
s = set(zero)