Under construction

Still being built. Things may change

Set

Interview

Time limit1.5sMemory limit4 MB

Summary
Maintain a set of integers 1 to 20 under add, remove, toggle, check, all, and empty, and print each check result.
Level

Easy3 of 10

Topics
Bit manipulation, Implementation
Solved
No attempts yet

Problem

You start with an empty set SS. Write a program that performs the following operations.

  • add x: adds xx to SS. If xx is already in SS, the operation is ignored.
  • remove x: removes xx from SS. If xx is not in SS, the operation is ignored.
  • check x: prints 1 if xx is in SS, and 0 otherwise.
  • toggle x: removes xx from SS if xx is in SS, and adds xx otherwise.
  • all: replaces SS with {1,2,…,20}\{1, 2, \ldots, 20\}.
  • empty: replaces SS with the empty set.

For add, remove, check and toggle, the argument satisfies 1≤x≤201 \le x \le 20.

Input

The first line contains the number of operations MM (1≤M≤3,000,0001 \le M \le 3{,}000{,}000).

Each of the next MM lines contains one operation. It is one of the six operations described above, and an operation that takes an argument has its name and xx separated by a single space.

Output

For every check operation, print its result on its own line, in the order the operations are given.

If there is no check operation, print nothing.

Examples1

  1. Example 1

    Input
    26
    add 1
    add 2
    check 1
    check 2
    check 3
    remove 2
    check 1
    check 2
    toggle 3
    check 1
    check 2
    check 3
    check 4
    all
    check 10
    check 20
    toggle 10
    remove 20
    check 10
    check 20
    empty
    check 1
    toggle 1
    check 1
    toggle 1
    check 1
    
    Expected output
    1
    1
    0
    1
    0
    1
    0
    1
    0
    1
    1
    0
    0
    0
    1
    0