#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
const int maxn = 200002;
const int maxnode = 32 * maxn;
const int LIMIT = 34;
int n;
int cc[LIMIT];
int ch[maxnode][2];
int rt = 0, ndtot = 0;
int val[maxnode];
void init() {
  memset((ch), 0, sizeof(ch));
  memset((val), 0, sizeof(val));
}
void binDecode(long long v) {
  memset((cc), 0, sizeof(cc));
  for (int i = 0; i < LIMIT; i++) {
    cc[LIMIT - 1 - i] = (v & 1);
    v /= 2;
  }
}
void insert(long long v) {
  binDecode(v);
  int u = rt;
  for (int i = 0; i < LIMIT; i++) {
    if (!ch[u][cc[i]]) ch[u][cc[i]] = ++ndtot;
    u = ch[u][cc[i]];
  }
  val[u]++;
}
void realDelete() {
  int u = rt;
  vector<int> path;
  path.push_back(rt);
  for (int i = 0; i < LIMIT; i++) {
    u = ch[u][cc[i]];
    path.push_back(u);
  }
  int which;
  for (int i = path.size() - 2; i >= 0; i--) {
    if (ch[path[i]][0] == path[i + 1]) {
      which = 0;
    } else {
      which = 1;
    }
    ch[path[i]][which] = 0;
    if (ch[path[i]][!which]) {
      break;
    }
  }
}
void remove(int v) {
  binDecode(v);
  int u = rt;
  bool notFound = false;
  for (int i = 0; i < LIMIT; i++) {
    if (!ch[u][cc[i]]) {
      notFound = true;
      break;
    }
    u = ch[u][cc[i]];
  }
  if (!notFound && val[u] > 0) {
    val[u]--;
    if (val[u] == 0) {
      realDelete();
    }
  }
}
long long query(long long v) {
  binDecode(v);
  int u = rt;
  long long result = 0;
  for (int i = 0; i < LIMIT; i++) {
    result <<= 1;
    if (ch[u][!cc[i]]) {
      u = ch[u][!cc[i]];
      result |= 1;
    } else {
      u = ch[u][cc[i]];
      result |= 0;
    }
  }
  return result;
}
int main() {
  init();
  scanf("%d", &n);
  insert(0);
  for (int i = 0; i < n; i++) {
    char cmd;
    int v;
    cin >> cmd >> v;
    switch (cmd) {
      case '+':
        insert(v);
        break;
      case '-':
        remove(v);
        break;
      case '?':
        int ans = query(v);
        cout << ans << endl;
        break;
    }
  }
  return 0;
}

### Prompt

Your task is to create a CPP solution to 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 INF = 100000000;
const int maxn = 200002;
const int maxnode = 32 * maxn;
const int LIMIT = 34;
int n;
int cc[LIMIT];
int ch[maxnode][2];
int rt = 0, ndtot = 0;
int val[maxnode];
void init() {
  memset((ch), 0, sizeof(ch));
  memset((val), 0, sizeof(val));
}
void binDecode(long long v) {
  memset((cc), 0, sizeof(cc));
  for (int i = 0; i < LIMIT; i++) {
    cc[LIMIT - 1 - i] = (v & 1);
    v /= 2;
  }
}
void insert(long long v) {
  binDecode(v);
  int u = rt;
  for (int i = 0; i < LIMIT; i++) {
    if (!ch[u][cc[i]]) ch[u][cc[i]] = ++ndtot;
    u = ch[u][cc[i]];
  }
  val[u]++;
}
void realDelete() {
  int u = rt;
  vector<int> path;
  path.push_back(rt);
  for (int i = 0; i < LIMIT; i++) {
    u = ch[u][cc[i]];
    path.push_back(u);
  }
  int which;
  for (int i = path.size() - 2; i >= 0; i--) {
    if (ch[path[i]][0] == path[i + 1]) {
      which = 0;
    } else {
      which = 1;
    }
    ch[path[i]][which] = 0;
    if (ch[path[i]][!which]) {
      break;
    }
  }
}
void remove(int v) {
  binDecode(v);
  int u = rt;
  bool notFound = false;
  for (int i = 0; i < LIMIT; i++) {
    if (!ch[u][cc[i]]) {
      notFound = true;
      break;
    }
    u = ch[u][cc[i]];
  }
  if (!notFound && val[u] > 0) {
    val[u]--;
    if (val[u] == 0) {
      realDelete();
    }
  }
}
long long query(long long v) {
  binDecode(v);
  int u = rt;
  long long result = 0;
  for (int i = 0; i < LIMIT; i++) {
    result <<= 1;
    if (ch[u][!cc[i]]) {
      u = ch[u][!cc[i]];
      result |= 1;
    } else {
      u = ch[u][cc[i]];
      result |= 0;
    }
  }
  return result;
}
int main() {
  init();
  scanf("%d", &n);
  insert(0);
  for (int i = 0; i < n; i++) {
    char cmd;
    int v;
    cin >> cmd >> v;
    switch (cmd) {
      case '+':
        insert(v);
        break;
      case '-':
        remove(v);
        break;
      case '?':
        int ans = query(v);
        cout << ans << endl;
        break;
    }
  }
  return 0;
}

```