#include <bits/stdc++.h>
using namespace std;
long long n;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T = int>
inline T readNxt() {
  char c = nc();
  T x = 0;
  int f = 1;
  for (; c > '9' || c < '0'; c = nc())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= f;
  return x;
}
struct TrieNode {
  struct TrieNode *zero;
  struct TrieNode *one;
  int cnt;
};
struct TrieNode *getNode(void) {
  struct TrieNode *pNode = new TrieNode;
  pNode->cnt = 0;
  pNode->zero = NULL;
  pNode->one = NULL;
  return pNode;
}
void insert(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  for (int i = key.size() - 1; i >= 0; i--) {
    if (key[i]) {
      if (!pCrawl->one) pCrawl->one = getNode();
      pCrawl = pCrawl->one;
    } else {
      if (!pCrawl->zero) pCrawl->zero = getNode();
      pCrawl = pCrawl->zero;
    }
    pCrawl->cnt += 1;
  }
}
bitset<31> search(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  bitset<31> tmp;
  tmp.reset();
  for (int i = key.size() - 1; i >= 0; i--) {
    if (!key[i]) {
      if (pCrawl->one && pCrawl->one->cnt)
        pCrawl = pCrawl->one, tmp[i] = 1;
      else
        pCrawl = pCrawl->zero;
    } else {
      if (pCrawl->zero && pCrawl->zero->cnt)
        pCrawl = pCrawl->zero;
      else
        pCrawl = pCrawl->one, tmp[i] = 1;
    }
  }
  return (key ^ tmp);
}
void del(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  for (int i = key.size() - 1; i >= 0; i--) {
    if (key[i]) {
      pCrawl = pCrawl->one;
      pCrawl->cnt -= 1;
    } else {
      pCrawl = pCrawl->zero;
      pCrawl->cnt -= 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie();
  string s;
  getline(cin, s);
  stringstream ss1(s);
  ss1 >> n;
  long long x = 0;
  struct TrieNode *root = getNode();
  bitset<31> init(0);
  insert(root, init);
  char c;
  while (n--) {
    getline(cin, s);
    stringstream ss(s);
    ss >> c >> x;
    bitset<31> b(x);
    if (c == '+') {
      insert(root, b);
      continue;
    }
    if (c == '-') {
      del(root, b);
      continue;
    }
    printf("%I64d\n", (long long)search(root, b).to_ulong());
  }
  return 0;
}

### Prompt

Please create a solution in Cpp 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;
long long n;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T = int>
inline T readNxt() {
  char c = nc();
  T x = 0;
  int f = 1;
  for (; c > '9' || c < '0'; c = nc())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= f;
  return x;
}
struct TrieNode {
  struct TrieNode *zero;
  struct TrieNode *one;
  int cnt;
};
struct TrieNode *getNode(void) {
  struct TrieNode *pNode = new TrieNode;
  pNode->cnt = 0;
  pNode->zero = NULL;
  pNode->one = NULL;
  return pNode;
}
void insert(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  for (int i = key.size() - 1; i >= 0; i--) {
    if (key[i]) {
      if (!pCrawl->one) pCrawl->one = getNode();
      pCrawl = pCrawl->one;
    } else {
      if (!pCrawl->zero) pCrawl->zero = getNode();
      pCrawl = pCrawl->zero;
    }
    pCrawl->cnt += 1;
  }
}
bitset<31> search(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  bitset<31> tmp;
  tmp.reset();
  for (int i = key.size() - 1; i >= 0; i--) {
    if (!key[i]) {
      if (pCrawl->one && pCrawl->one->cnt)
        pCrawl = pCrawl->one, tmp[i] = 1;
      else
        pCrawl = pCrawl->zero;
    } else {
      if (pCrawl->zero && pCrawl->zero->cnt)
        pCrawl = pCrawl->zero;
      else
        pCrawl = pCrawl->one, tmp[i] = 1;
    }
  }
  return (key ^ tmp);
}
void del(struct TrieNode *root, bitset<31> key) {
  struct TrieNode *pCrawl = root;
  for (int i = key.size() - 1; i >= 0; i--) {
    if (key[i]) {
      pCrawl = pCrawl->one;
      pCrawl->cnt -= 1;
    } else {
      pCrawl = pCrawl->zero;
      pCrawl->cnt -= 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie();
  string s;
  getline(cin, s);
  stringstream ss1(s);
  ss1 >> n;
  long long x = 0;
  struct TrieNode *root = getNode();
  bitset<31> init(0);
  insert(root, init);
  char c;
  while (n--) {
    getline(cin, s);
    stringstream ss(s);
    ss >> c >> x;
    bitset<31> b(x);
    if (c == '+') {
      insert(root, b);
      continue;
    }
    if (c == '-') {
      del(root, b);
      continue;
    }
    printf("%I64d\n", (long long)search(root, b).to_ulong());
  }
  return 0;
}

```