#include <bits/stdc++.h>
using namespace std;
const int Log = 30;
const int Max = 2e5 + 5;
char c;
int n, x, b = 1;
int v[Log + 5];
void Bil(int x) {
  int y = Log;
  memset(v, 0, sizeof(v));
  while (x) v[y--] = x & 1, x >>= 1;
}
struct Trie {
  int t[Max * Log][2], a[Max * Log][2];
  void sifir() {
    memset(t, 0, sizeof(t));
    memset(a, 0, sizeof(a));
  }
  void add(int x) {
    Bil(x);
    int pos = 1, yr = 0;
    while (yr <= Log) {
      a[pos][v[yr]]++;
      if (t[pos][v[yr]])
        pos = t[pos][v[yr]];
      else if (!t[pos][v[yr]])
        b++, t[pos][v[yr]] = b, pos = b;
      yr++;
    }
  }
  void del(int x) {
    Bil(x);
    int pos = 1, yr = 0;
    while (yr <= Log) {
      a[pos][v[yr]]--;
      if (!a[pos][v[yr]]) t[pos][v[yr]] = 0;
      pos = t[pos][v[yr]];
      yr++;
    }
  }
  int tap(int x) {
    Bil(x);
    int pos = 1, yr = 0, res = 0;
    while (yr <= Log) {
      if (!t[pos][1 - v[yr]])
        pos = t[pos][v[yr]];
      else if (t[pos][1 - v[yr]])
        res += (1 << (Log - yr)), pos = t[pos][1 - v[yr]];
      yr++;
    }
    return res;
  }
} trie;
int main() {
  scanf("%d", &n);
  trie.sifir();
  trie.add(0);
  for (int h = 1; h <= n; h++) {
    scanf(" %c%d", &c, &x);
    if (c == '+') trie.add(x);
    if (c == '-') trie.del(x);
    if (c == '?') printf("%d\n", trie.tap(x));
  }
}

### Prompt

In CPP, your task is to solve the following problem:

Author has gone out of the stories about Vasiliy, so here is just a formal task description.

You are given q queries and a multiset A, initially containing only integer 0. There are three types of queries:

  1. "+ x" — add integer x to multiset A.
  2. "- x" — erase one occurrence of integer x from multiset A. It's guaranteed that at least one x is present in the multiset A before this query.
  3. "? x" — you are given integer x and need to compute the value <image>, i.e. the maximum value of bitwise exclusive OR (also know as XOR) of integer x and some integer y from the multiset A.



Multiset is a set, where equal elements are allowed.

Input

The first line of the input contains a single integer q (1 ≤ q ≤ 200 000) — the number of queries Vasiliy has to perform.

Each of the following q lines of the input contains one of three characters '+', '-' or '?' and an integer xi (1 ≤ xi ≤ 109). It's guaranteed that there is at least one query of the third type.

Note, that the integer 0 will always be present in the set A.

Output

For each query of the type '?' print one integer — the maximum value of bitwise exclusive OR (XOR) of integer xi and some integer from the multiset A.

Example

Input

10
+ 8
+ 9
+ 11
+ 6
+ 1
? 3
- 8
? 3
? 8
? 11


Output

11
10
14
13

Note

After first five operations multiset A contains integers 0, 8, 9, 11, 6 and 1.

The answer for the sixth query is integer <image> — maximum among integers <image>, <image>, <image>, <image> and <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int Log = 30;
const int Max = 2e5 + 5;
char c;
int n, x, b = 1;
int v[Log + 5];
void Bil(int x) {
  int y = Log;
  memset(v, 0, sizeof(v));
  while (x) v[y--] = x & 1, x >>= 1;
}
struct Trie {
  int t[Max * Log][2], a[Max * Log][2];
  void sifir() {
    memset(t, 0, sizeof(t));
    memset(a, 0, sizeof(a));
  }
  void add(int x) {
    Bil(x);
    int pos = 1, yr = 0;
    while (yr <= Log) {
      a[pos][v[yr]]++;
      if (t[pos][v[yr]])
        pos = t[pos][v[yr]];
      else if (!t[pos][v[yr]])
        b++, t[pos][v[yr]] = b, pos = b;
      yr++;
    }
  }
  void del(int x) {
    Bil(x);
    int pos = 1, yr = 0;
    while (yr <= Log) {
      a[pos][v[yr]]--;
      if (!a[pos][v[yr]]) t[pos][v[yr]] = 0;
      pos = t[pos][v[yr]];
      yr++;
    }
  }
  int tap(int x) {
    Bil(x);
    int pos = 1, yr = 0, res = 0;
    while (yr <= Log) {
      if (!t[pos][1 - v[yr]])
        pos = t[pos][v[yr]];
      else if (t[pos][1 - v[yr]])
        res += (1 << (Log - yr)), pos = t[pos][1 - v[yr]];
      yr++;
    }
    return res;
  }
} trie;
int main() {
  scanf("%d", &n);
  trie.sifir();
  trie.add(0);
  for (int h = 1; h <= n; h++) {
    scanf(" %c%d", &c, &x);
    if (c == '+') trie.add(x);
    if (c == '-') trie.del(x);
    if (c == '?') printf("%d\n", trie.tap(x));
  }
}

```