#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T on(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%I64d", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
string go(int n) {
  string s;
  while (n) {
    int p = n % 2;
    p = p + '0';
    s += p;
    n /= 2;
  }
  while (s.size() != 30) s += '0';
  reverse(s.begin(), s.end());
  return s;
}
long long int go(string s) {
  long long int p = 0;
  for (int i = 0; i < s.length(); i++) p = (p * 2) + (s[i] - 48);
  return p;
}
int sz = 1;
struct Trie {
  int node[3];
  int counter[3];
  bool endmark;
  Trie() {
    endmark = 0;
    for (int i = 0; i < 3; i++) node[i] = 0;
  }
} trie[6000010];
void Insert(string s) {
  int v = 0;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    if (trie[v].node[c] == 0) {
      trie[v].node[c] = sz++;
    }
    trie[v].counter[c]++;
    v = trie[v].node[c];
  }
  trie[v].endmark = true;
}
bool del(string s) {
  int v = 0;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    trie[v].counter[c]--;
    v = trie[v].node[c];
  }
}
string query(string s) {
  int v = 0;
  string m;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    if (c == 1) {
      if (trie[v].counter[0]) {
        m += '1';
        v = trie[v].node[0];
      } else {
        m += '0';
        v = trie[v].node[1];
      }
    } else {
      if (trie[v].counter[1]) {
        m += '1';
        v = trie[v].node[1];
      } else {
        m += '0';
        v = trie[v].node[0];
      }
    }
  }
  return m;
}
int main() {
  Insert(go(0));
  int n = nxt();
  while (n--) {
    char a;
    int b;
    cin >> a >> b;
    string x = go(b);
    if (a == '+') {
      Insert(x);
    } else if (a == '-') {
      del(x);
    } else {
      string s = query(x);
      printf("%I64d\n", go(s));
    }
  }
  return 0;
}

### Prompt

Create a solution in cpp for 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;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T on(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%I64d", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
string go(int n) {
  string s;
  while (n) {
    int p = n % 2;
    p = p + '0';
    s += p;
    n /= 2;
  }
  while (s.size() != 30) s += '0';
  reverse(s.begin(), s.end());
  return s;
}
long long int go(string s) {
  long long int p = 0;
  for (int i = 0; i < s.length(); i++) p = (p * 2) + (s[i] - 48);
  return p;
}
int sz = 1;
struct Trie {
  int node[3];
  int counter[3];
  bool endmark;
  Trie() {
    endmark = 0;
    for (int i = 0; i < 3; i++) node[i] = 0;
  }
} trie[6000010];
void Insert(string s) {
  int v = 0;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    if (trie[v].node[c] == 0) {
      trie[v].node[c] = sz++;
    }
    trie[v].counter[c]++;
    v = trie[v].node[c];
  }
  trie[v].endmark = true;
}
bool del(string s) {
  int v = 0;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    trie[v].counter[c]--;
    v = trie[v].node[c];
  }
}
string query(string s) {
  int v = 0;
  string m;
  for (int i = 0; i < s.length(); i++) {
    int c = s[i] - '0';
    if (c == 1) {
      if (trie[v].counter[0]) {
        m += '1';
        v = trie[v].node[0];
      } else {
        m += '0';
        v = trie[v].node[1];
      }
    } else {
      if (trie[v].counter[1]) {
        m += '1';
        v = trie[v].node[1];
      } else {
        m += '0';
        v = trie[v].node[0];
      }
    }
  }
  return m;
}
int main() {
  Insert(go(0));
  int n = nxt();
  while (n--) {
    char a;
    int b;
    cin >> a >> b;
    string x = go(b);
    if (a == '+') {
      Insert(x);
    } else if (a == '-') {
      del(x);
    } else {
      string s = query(x);
      printf("%I64d\n", go(s));
    }
  }
  return 0;
}

```