# XOR Sum Queries
## Problem Statement
You are given an empty set $S$. You need to process $n$ queries on this set. Let $X$ denote the set of all possible XOR sums of elements from any subset of $S$. The empty subset has an XOR sum of $0$.
There are two types of queries:
1. **Type 1: Insert**
Given an integer $k$, insert $k$ into the set $S$. If $k$ is already present in $S$, do nothing.
2. **Type 2: Query $k$-th Highest**
Given an integer $k$, find and print the $k$-th highest number from the set $X$. It is guaranteed that $1 \le k \le |X|$ at the time of the query.
## Input Format
- The first line contains a single integer $n$ ($1 \le n \le 10^5$), the number of queries.
- Each of the following $n$ lines describes a query:
- If the query is of Type 1, it will be given in the format `1 k` ($1 \le k \le 10^9$).
- If the query is of Type 2, it will be given in the format `2 k` ($1 \le k \le 2^{30}$). Note that $k$ is guaranteed to be less than or equal to $|X|$.
## Output Format
For each Type 2 query, print the $k$-th highest XOR sum from $X$ on a new line.
## Sample Test Cases
### Sample Input 1
```
6
1 6
1 3
2 1
2 2
2 3
2 4
```
### Sample Output 1
```
6
5
3
0
```
### Sample Input 2
```
5
1 7
1 10
1 12
2 1
2 8
```
### Sample Output 2
```
14
0
```
## Constraints
- $1 \le n \le 10^5$
- For Type 1 queries, $1 \le k \le 10^9$
- For Type 2 queries, $1 \le k \le 2^{30}$ (and $k \le |X|$ is guaranteed)
- Time limit: 1 second
- Memory limit: 256 MB
## Explanation
### Sample 1
1. `1 6`: $S = \{6\}$. The basis for XOR sums is effectively $\{6\}$. The set of all possible XOR sums is $X = \{0, 6\}$.
2. `1 3`: $S = \{6, 3\}$. A basis for these elements can be constructed, for example, $\{6, 3\}$ (or $\{6, 5\}$ after reduction). The set of all possible XOR sums $X = \{0, 3, 5, 6\}$. Sorted in descending order, these are $6, 5, 3, 0$.
3. `2 1`: The 1st highest number in $X$ is $6$.
4. `2 2`: The 2nd highest number in $X$ is $5$.
5. `2 3`: The 3rd highest number in $X$ is $3$.
6. `2 4`: The 4th highest number in $X$ is $0$.
### Sample 2
1. `1 7`: $S=\{7\}$. Basis: $\{7\}$. $X = \{0, 7\}$.
2. `1 10`: $S=\{7, 10\}$. Basis: $\{7, 10\}$. $X = \{0, 7, 10, 7 \oplus 10 = 13\}$.
3. `1 12`: $S=\{7, 10, 12\}$. After inserting and reducing, the basis will contain 3 independent elements, e.g., $\{10, 7, 1\}$. The size of the basis is $3$, so $|X| = 2^3 = 8$.
The 8 possible XOR sums are $0, 1, 6, 7, 10, 11, 13, 14$. Sorted in descending order: $14, 13, 11, 10, 7, 6, 1, 0$.
4. `2 1`: The 1st highest number in $X$ is $14$.
5. `2 8`: The 8th highest number in $X$ is $0$.
Loading problem statement...