#include <bits/stdc++.h>
using namespace std;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  if (t.size() == 0) {
    s << "[]";
    return s;
  }
  s << "[";
  for (int i = 0; i < ((int)(t.size())) - 1; i++) s << t[i] << ", ";
  s << t[((int)(t.size())) - 1] << "]";
  return s;
}
template <typename T, typename TT>
ostream& operator<<(ostream& s, map<T, TT> m) {
  if (m.size() == 0) {
    s << "{}";
    return s;
  }
  s << "{";
  auto nxt = m.begin(), it = nxt++;
  for (; nxt != m.end(); it++, nxt++) s << *it << ", ";
  s << *it << "}";
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, set<T> m) {
  if (m.size() == 0) {
    s << "()";
    return s;
  }
  s << "(";
  auto nxt = m.begin(), it = nxt++;
  for (; nxt != m.end(); it++, nxt++) s << *it << ", ";
  s << *it << ")";
  return s;
}
const int MOD = 1e9 + 7;
template <typename T>
inline T gcD(T a, T b) {
  if (a < b) swap(a, b);
  while (b) a %= b, swap(a, b);
  return a;
}
template <typename T>
inline T pow_mod(T a, T b) {
  T res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
const int MAXN = 3e6;
int trie[MAXN][2];
int data[MAXN][2];
int t = 0;
void init_trie() { trie[0][0] = trie[0][1] = -1; }
void add(int x) {
  int ind = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    if (trie[ind][b] == -1) {
      trie[ind][b] = ++t;
      trie[t][0] = trie[t][1] = -1;
    }
    data[ind][b]++;
    ind = trie[ind][b];
  }
}
void erase(int x) {
  int ind = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    data[ind][b]--;
    ind = trie[ind][b];
  }
}
int max_xor(int x) {
  int ind = 0;
  int ans = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    b = 1 - b;
    if (trie[ind][b] != -1 && data[ind][b] != 0) {
      ans += 1 << i;
      ind = trie[ind][b];
    } else if (trie[ind][1 - b] != -1 && data[ind][1 - b] != 0) {
      ind = trie[ind][1 - b];
    } else {
      assert(false);
    }
  }
  return ans;
}
string a;
int main() {
  ios_base::sync_with_stdio(false);
  memset(data, 0, sizeof data);
  init_trie();
  int n;
  cin >> n;
  add(0);
  while (n--) {
    int x;
    cin >> a >> x;
    if (a[0] == '+') {
      add(x);
    } else if (a[0] == '-') {
      erase(x);
    } else if (a[0] == '?') {
      cout << max_xor(x) << endl;
    }
  }
}

### 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 fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  if (t.size() == 0) {
    s << "[]";
    return s;
  }
  s << "[";
  for (int i = 0; i < ((int)(t.size())) - 1; i++) s << t[i] << ", ";
  s << t[((int)(t.size())) - 1] << "]";
  return s;
}
template <typename T, typename TT>
ostream& operator<<(ostream& s, map<T, TT> m) {
  if (m.size() == 0) {
    s << "{}";
    return s;
  }
  s << "{";
  auto nxt = m.begin(), it = nxt++;
  for (; nxt != m.end(); it++, nxt++) s << *it << ", ";
  s << *it << "}";
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, set<T> m) {
  if (m.size() == 0) {
    s << "()";
    return s;
  }
  s << "(";
  auto nxt = m.begin(), it = nxt++;
  for (; nxt != m.end(); it++, nxt++) s << *it << ", ";
  s << *it << ")";
  return s;
}
const int MOD = 1e9 + 7;
template <typename T>
inline T gcD(T a, T b) {
  if (a < b) swap(a, b);
  while (b) a %= b, swap(a, b);
  return a;
}
template <typename T>
inline T pow_mod(T a, T b) {
  T res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
const int MAXN = 3e6;
int trie[MAXN][2];
int data[MAXN][2];
int t = 0;
void init_trie() { trie[0][0] = trie[0][1] = -1; }
void add(int x) {
  int ind = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    if (trie[ind][b] == -1) {
      trie[ind][b] = ++t;
      trie[t][0] = trie[t][1] = -1;
    }
    data[ind][b]++;
    ind = trie[ind][b];
  }
}
void erase(int x) {
  int ind = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    data[ind][b]--;
    ind = trie[ind][b];
  }
}
int max_xor(int x) {
  int ind = 0;
  int ans = 0;
  for (int i = 31; i >= 0; i--) {
    int b = (((x) >> (i)) & 1);
    b = 1 - b;
    if (trie[ind][b] != -1 && data[ind][b] != 0) {
      ans += 1 << i;
      ind = trie[ind][b];
    } else if (trie[ind][1 - b] != -1 && data[ind][1 - b] != 0) {
      ind = trie[ind][1 - b];
    } else {
      assert(false);
    }
  }
  return ans;
}
string a;
int main() {
  ios_base::sync_with_stdio(false);
  memset(data, 0, sizeof data);
  init_trie();
  int n;
  cin >> n;
  add(0);
  while (n--) {
    int x;
    cin >> a >> x;
    if (a[0] == '+') {
      add(x);
    } else if (a[0] == '-') {
      erase(x);
    } else if (a[0] == '?') {
      cout << max_xor(x) << endl;
    }
  }
}

```