#include <bits/stdc++.h>
using namespace std;
char RR[30000005], *S = RR;
inline int read() {
  int p = 0, w = 1;
  char c = *S++;
  while (c > '9' || c < '0') {
    if (c == '-') w = -1;
    c = *S++;
  }
  while (c >= '0' && c <= '9') {
    p = p * 10 + c - '0';
    c = *S++;
  }
  return p * w;
}
inline int Get_opt() {
  char ch = *S++;
  while (1) {
    if (ch == '+') return 1;
    if (ch == '-') return 2;
    if (ch == '?') return 3;
    ch = *S++;
  }
}
int q, tot;
int tp[50];
int son[8000005][2];
int cnt[8000005];
inline void Insert(int tim) {
  int x;
  if (tim == 0)
    x = 0;
  else
    x = read();
  int opt, e = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    if (!son[e][opt]) son[e][opt] = ++tot;
    e = son[e][opt];
    cnt[e]++;
  }
}
inline void Delete() {
  int x = read();
  if (x == 0) return;
  int opt, e = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    e = son[e][opt];
    cnt[e]--;
  }
}
inline void Query() {
  int x = read();
  int opt, e = 0, ans = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    if (son[e][opt ^ 1] && cnt[son[e][opt ^ 1]])
      e = son[e][opt ^ 1], ans += tp[i];
    else
      e = son[e][opt];
  }
  printf("%d\n", ans);
}
int main() {
  fread(RR, 1, sizeof(RR), stdin);
  q = read();
  for (int i = 0; i <= 30; i++) tp[i] = 1 << i;
  Insert(0);
  for (int i = 1; i <= q; i++) {
    int opt = Get_opt();
    if (opt == 1) Insert(1);
    if (opt == 2) Delete();
    if (opt == 3) Query();
  }
  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;
char RR[30000005], *S = RR;
inline int read() {
  int p = 0, w = 1;
  char c = *S++;
  while (c > '9' || c < '0') {
    if (c == '-') w = -1;
    c = *S++;
  }
  while (c >= '0' && c <= '9') {
    p = p * 10 + c - '0';
    c = *S++;
  }
  return p * w;
}
inline int Get_opt() {
  char ch = *S++;
  while (1) {
    if (ch == '+') return 1;
    if (ch == '-') return 2;
    if (ch == '?') return 3;
    ch = *S++;
  }
}
int q, tot;
int tp[50];
int son[8000005][2];
int cnt[8000005];
inline void Insert(int tim) {
  int x;
  if (tim == 0)
    x = 0;
  else
    x = read();
  int opt, e = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    if (!son[e][opt]) son[e][opt] = ++tot;
    e = son[e][opt];
    cnt[e]++;
  }
}
inline void Delete() {
  int x = read();
  if (x == 0) return;
  int opt, e = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    e = son[e][opt];
    cnt[e]--;
  }
}
inline void Query() {
  int x = read();
  int opt, e = 0, ans = 0;
  for (int i = 30; ~i; i--) {
    if (tp[i] & x)
      opt = 1;
    else
      opt = 0;
    if (son[e][opt ^ 1] && cnt[son[e][opt ^ 1]])
      e = son[e][opt ^ 1], ans += tp[i];
    else
      e = son[e][opt];
  }
  printf("%d\n", ans);
}
int main() {
  fread(RR, 1, sizeof(RR), stdin);
  q = read();
  for (int i = 0; i <= 30; i++) tp[i] = 1 << i;
  Insert(0);
  for (int i = 1; i <= q; i++) {
    int opt = Get_opt();
    if (opt == 1) Insert(1);
    if (opt == 2) Delete();
    if (opt == 3) Query();
  }
  return 0;
}

```