Problem8840--[yosupo] Data Structure - Set Xor-Min

8840: [yosupo] Data Structure - Set Xor-Min

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Let $S$ be an empty integer set.
Process the following $Q$ queries :
 - 0 x : insert $x$ into $S$ if it is not in $S$
 - 1 x : remove $x$ from $S$ if it is in $S$
 - 2 x : find $\min_{i \in S}(i \oplus x)$ where $\oplus$ denotes bitwise-xor.

Input

$Q$
$\mathrm{Query}_0$
$\mathrm{Query}_1$
$\mathrm{Query}_2$
$\hspace{15pt} \vdots$
$\mathrm{Query}_{Q - 1}$

Constraints

$1 \leq Q \leq 500000$
$0 \le x \lt 2^{30}$
$S$ is not empty when processing queries of type 2 x.

Sample 1 Input

6
0 6
0 7
2 5
1 7
1 10
2 7

Sample 1 Output

2
1

HINT

相同题目:yosupo

Source/Category