#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a < b)
    return gcd(b, a);
  else if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int isPrime(long long int n) {
  long long int p = (long long int)sqrt(n);
  for (long long int i = (2); i <= (p); i += (1))
    if (n % i == 0) return 0;
  return 1;
}
long long int pow(long long int b, long long int e) {
  if (e == 0)
    return 1;
  else if (e % 2 == 0) {
    long long int a = pow(b, e / 2);
    return a * a;
  } else {
    long long int a = pow(b, e / 2);
    return b * a * a;
  }
}
long long int powm(long long int x, long long int y,
                   long long int m = 1000000007) {
  x = x % m;
  long long int res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= m;
    y = y >> 1;
    x = x * x;
    x %= m;
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int modInverse(long long int a, long long int m) {
  return powm(a, m - 2, m);
}
bool issq(long long int n) {
  long long int p = sqrt(n);
  return p * p == n;
}
long long int MIN(long long int a = 2e18, long long int b = 2e18,
                  long long int c = 2e18, long long int d = 2e18,
                  long long int e = 2e18) {
  return min(a, min(b, min(c, min(d, e))));
}
long long int MAX(long long int a = -2e18, long long int b = -2e18,
                  long long int c = -2e18, long long int d = -2e18,
                  long long int e = -2e18) {
  return max(a, max(b, max(c, max(d, e))));
}
vector<long long int> prime;
void seive(long long int n) {
  prime.resize(n + 1);
  for (long long int i = (2); i <= (n); i += (1))
    if (prime[i] == 0) {
      prime[i] = i;
      for (long long int j = (i * i); j <= (n); j += (i))
        if (prime[j] == 0) prime[j] = i;
    }
}
long long int extended_GCD(long long int a, long long int b, long long int& x,
                           long long int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int mulInv(long long int a, long long int mod) {
  long long int x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
template <typename T>
void swap(T* x, T* y) {
  T z = *x;
  *x = *y;
  *y = z;
}
template <typename T>
void print(T a[], long long int start, long long int end) {
  for (long long int i = (start); i <= (end); i += (1)) cout << a[i] << " ";
  cout << "\n";
}
template <typename T>
void print(T a, long long int start = 0, long long int end = 1e9) {
  end = min(end, (long long int)a.size() - 1);
  for (long long int i = (start); i <= (end); i += (1)) cout << a[i] << " ";
  cout << "\n";
}
template <typename T, typename P>
void print(vector<pair<T, P>> v, long long int start = 0,
           long long int end = 1e9) {
  end = min(end, (long long int)v.size() - 1);
  for (long long int i = (start); i <= (end); i += (1))
    cout << v[i].first << " " << v[i].second, cout << "\n";
  ;
}
long long int find(long long int num[], long long int rem[], long long int k,
                   long long int prod) {
  long long int result = 0;
  for (long long int i = 0; i < k; i++) {
    long long int pp = prod / num[i];
    result += rem[i] * mulInv(pp, num[i]) * pp;
  }
  return result % prod;
}
class DSU {
 public:
  vector<long long int> a, rank;

 public:
  long long int c;
  map<string, long long int> m;

 public:
  DSU(long long int n) {
    c = 1;
    a.resize(n + 1);
    rank.resize(n + 1);
    for (long long int i = 1; i <= n; i++) {
      a[i] = i;
      rank[i] = 1;
    }
  }

 public:
  long long int root(long long int x) {
    long long int u = x;
    while (a[x] != x) {
      a[x] = a[a[x]];
      x = a[x];
    }
    a[u] = x;
    return x;
  }

 public:
  void unite(long long int x, long long int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (rank[x] < rank[y]) {
        a[y] = x;
        rank[x] += rank[y];
      } else {
        a[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
class Segment {
 public:
  vector<long long int> tree, arr;

 public:
  Segment(long long int n, long long int a[]) {
    tree.resize(4 * n + 1);
    arr.resize(n + 1);
    for (long long int i = (1); i <= (n); i += (1)) arr[i] = a[i];
    build(1, 1, n);
  }

 public:
  void build(long long int node, long long int l, long long int r) {
    if (l == r)
      tree[node] = arr[l];
    else {
      long long int mid = (l + r) / 2;
      build(node * 2, l, mid);
      build(node * 2 + 1, mid + 1, r);
      tree[node] = min(tree[2 * node], tree[2 * node + 1]);
    }
  }

 public:
  void update(long long int ind, long long int val, long long int node,
              long long int l, long long int r) {
    long long int mid = (l + r) / 2;
    if (l == r) {
      tree[node] = val;
      arr[ind] = val;
    } else {
      if (ind <= mid)
        update(ind, val, 2 * node, l, mid);
      else
        update(ind, val, 2 * node + 1, 1 + mid, r);
      tree[node] = min(tree[2 * node], tree[2 * node + 1]);
    }
  }
  long long int get(long long int p, long long int q, long long int l,
                    long long int r, long long int node) {
    long long int mid = (l + r) / 2;
    if (p <= l && r <= q)
      return tree[node];
    else if (l > q || r < p)
      return 1e18;
    else
      return min(get(p, q, l, mid, 2 * node),
                 get(p, q, mid + 1, r, 2 * node + 1));
  }
};
struct trip {
  long long int d, f, b, ind;
};
bool comp(pair<long long int, pair<long long int, long long int>> p1,
          pair<long long int, pair<long long int, long long int>> p2) {
  return (p1.first < p2.first);
}
vector<long long int> visi;
void dfs(long long int n, vector<long long int> adj[], long long int par) {
  long long int l = (adj[n]).size();
  visi[n] = 1;
  for (long long int i = (0); i <= (l - 1); i += (1)) {
    if (visi[(adj[n])[i]] == 0) {
      dfs((adj[n])[i], adj, n);
    }
  }
}
struct trie {
  bool leaf = false;
  trie* child[2];
  long long int num = 0;
};
class Trie {
  trie* root;

 public:
  Trie() { root = create(); }

 public:
  trie* create() {
    trie* temp = new trie();
    temp->leaf = false;
    for (int i = 0; i < 2; i++) temp->child[i] = NULL;
    return temp;
  }

 public:
  void add(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* rt = root;
    while (!st.empty()) {
      if (rt->child[st.top()] == NULL) rt->child[st.top()] = create();
      rt = rt->child[st.top()];
      rt->num++;
      st.pop();
    }
  }

 public:
  void del(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* rt = root;
    while (!st.empty()) {
      rt->child[st.top()]->num--;
      if (rt->child[st.top()]->num == 0) {
        rt->child[st.top()] = NULL;
        break;
      }
      rt = rt->child[st.top()];
      st.pop();
    }
  }

 public:
  long long int find(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* tmp = root;
    long long int ans = 0;
    for (long long int i = 0; i < 31; i++) {
      long long int k = st.top();
      st.pop();
      if ((tmp->child[1 - k]) != NULL) {
        ans += pow(2, 30 - i);
        tmp = tmp->child[1 - k];
      } else {
        tmp = tmp->child[k];
      }
    }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Trie data;
  data.add(0);
  long long int T;
  cin >> T;
  while (T--) {
    string s;
    long long int n;
    cin >> s >> n;
    if (s == "+")
      data.add(n);
    else if (s == "-")
      data.del(n);
    else
      cout << data.find(n), cout << "\n";
    ;
  }
  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;
long long int gcd(long long int a, long long int b) {
  if (a < b)
    return gcd(b, a);
  else if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int isPrime(long long int n) {
  long long int p = (long long int)sqrt(n);
  for (long long int i = (2); i <= (p); i += (1))
    if (n % i == 0) return 0;
  return 1;
}
long long int pow(long long int b, long long int e) {
  if (e == 0)
    return 1;
  else if (e % 2 == 0) {
    long long int a = pow(b, e / 2);
    return a * a;
  } else {
    long long int a = pow(b, e / 2);
    return b * a * a;
  }
}
long long int powm(long long int x, long long int y,
                   long long int m = 1000000007) {
  x = x % m;
  long long int res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= m;
    y = y >> 1;
    x = x * x;
    x %= m;
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int modInverse(long long int a, long long int m) {
  return powm(a, m - 2, m);
}
bool issq(long long int n) {
  long long int p = sqrt(n);
  return p * p == n;
}
long long int MIN(long long int a = 2e18, long long int b = 2e18,
                  long long int c = 2e18, long long int d = 2e18,
                  long long int e = 2e18) {
  return min(a, min(b, min(c, min(d, e))));
}
long long int MAX(long long int a = -2e18, long long int b = -2e18,
                  long long int c = -2e18, long long int d = -2e18,
                  long long int e = -2e18) {
  return max(a, max(b, max(c, max(d, e))));
}
vector<long long int> prime;
void seive(long long int n) {
  prime.resize(n + 1);
  for (long long int i = (2); i <= (n); i += (1))
    if (prime[i] == 0) {
      prime[i] = i;
      for (long long int j = (i * i); j <= (n); j += (i))
        if (prime[j] == 0) prime[j] = i;
    }
}
long long int extended_GCD(long long int a, long long int b, long long int& x,
                           long long int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long int mulInv(long long int a, long long int mod) {
  long long int x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
template <typename T>
void swap(T* x, T* y) {
  T z = *x;
  *x = *y;
  *y = z;
}
template <typename T>
void print(T a[], long long int start, long long int end) {
  for (long long int i = (start); i <= (end); i += (1)) cout << a[i] << " ";
  cout << "\n";
}
template <typename T>
void print(T a, long long int start = 0, long long int end = 1e9) {
  end = min(end, (long long int)a.size() - 1);
  for (long long int i = (start); i <= (end); i += (1)) cout << a[i] << " ";
  cout << "\n";
}
template <typename T, typename P>
void print(vector<pair<T, P>> v, long long int start = 0,
           long long int end = 1e9) {
  end = min(end, (long long int)v.size() - 1);
  for (long long int i = (start); i <= (end); i += (1))
    cout << v[i].first << " " << v[i].second, cout << "\n";
  ;
}
long long int find(long long int num[], long long int rem[], long long int k,
                   long long int prod) {
  long long int result = 0;
  for (long long int i = 0; i < k; i++) {
    long long int pp = prod / num[i];
    result += rem[i] * mulInv(pp, num[i]) * pp;
  }
  return result % prod;
}
class DSU {
 public:
  vector<long long int> a, rank;

 public:
  long long int c;
  map<string, long long int> m;

 public:
  DSU(long long int n) {
    c = 1;
    a.resize(n + 1);
    rank.resize(n + 1);
    for (long long int i = 1; i <= n; i++) {
      a[i] = i;
      rank[i] = 1;
    }
  }

 public:
  long long int root(long long int x) {
    long long int u = x;
    while (a[x] != x) {
      a[x] = a[a[x]];
      x = a[x];
    }
    a[u] = x;
    return x;
  }

 public:
  void unite(long long int x, long long int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (rank[x] < rank[y]) {
        a[y] = x;
        rank[x] += rank[y];
      } else {
        a[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
class Segment {
 public:
  vector<long long int> tree, arr;

 public:
  Segment(long long int n, long long int a[]) {
    tree.resize(4 * n + 1);
    arr.resize(n + 1);
    for (long long int i = (1); i <= (n); i += (1)) arr[i] = a[i];
    build(1, 1, n);
  }

 public:
  void build(long long int node, long long int l, long long int r) {
    if (l == r)
      tree[node] = arr[l];
    else {
      long long int mid = (l + r) / 2;
      build(node * 2, l, mid);
      build(node * 2 + 1, mid + 1, r);
      tree[node] = min(tree[2 * node], tree[2 * node + 1]);
    }
  }

 public:
  void update(long long int ind, long long int val, long long int node,
              long long int l, long long int r) {
    long long int mid = (l + r) / 2;
    if (l == r) {
      tree[node] = val;
      arr[ind] = val;
    } else {
      if (ind <= mid)
        update(ind, val, 2 * node, l, mid);
      else
        update(ind, val, 2 * node + 1, 1 + mid, r);
      tree[node] = min(tree[2 * node], tree[2 * node + 1]);
    }
  }
  long long int get(long long int p, long long int q, long long int l,
                    long long int r, long long int node) {
    long long int mid = (l + r) / 2;
    if (p <= l && r <= q)
      return tree[node];
    else if (l > q || r < p)
      return 1e18;
    else
      return min(get(p, q, l, mid, 2 * node),
                 get(p, q, mid + 1, r, 2 * node + 1));
  }
};
struct trip {
  long long int d, f, b, ind;
};
bool comp(pair<long long int, pair<long long int, long long int>> p1,
          pair<long long int, pair<long long int, long long int>> p2) {
  return (p1.first < p2.first);
}
vector<long long int> visi;
void dfs(long long int n, vector<long long int> adj[], long long int par) {
  long long int l = (adj[n]).size();
  visi[n] = 1;
  for (long long int i = (0); i <= (l - 1); i += (1)) {
    if (visi[(adj[n])[i]] == 0) {
      dfs((adj[n])[i], adj, n);
    }
  }
}
struct trie {
  bool leaf = false;
  trie* child[2];
  long long int num = 0;
};
class Trie {
  trie* root;

 public:
  Trie() { root = create(); }

 public:
  trie* create() {
    trie* temp = new trie();
    temp->leaf = false;
    for (int i = 0; i < 2; i++) temp->child[i] = NULL;
    return temp;
  }

 public:
  void add(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* rt = root;
    while (!st.empty()) {
      if (rt->child[st.top()] == NULL) rt->child[st.top()] = create();
      rt = rt->child[st.top()];
      rt->num++;
      st.pop();
    }
  }

 public:
  void del(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* rt = root;
    while (!st.empty()) {
      rt->child[st.top()]->num--;
      if (rt->child[st.top()]->num == 0) {
        rt->child[st.top()] = NULL;
        break;
      }
      rt = rt->child[st.top()];
      st.pop();
    }
  }

 public:
  long long int find(long long int n) {
    stack<long long int> st;
    while (n) {
      st.push(n & 1);
      n = n >> 1;
    }
    while (st.size() != 31) st.push(0);
    trie* tmp = root;
    long long int ans = 0;
    for (long long int i = 0; i < 31; i++) {
      long long int k = st.top();
      st.pop();
      if ((tmp->child[1 - k]) != NULL) {
        ans += pow(2, 30 - i);
        tmp = tmp->child[1 - k];
      } else {
        tmp = tmp->child[k];
      }
    }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Trie data;
  data.add(0);
  long long int T;
  cin >> T;
  while (T--) {
    string s;
    long long int n;
    cin >> s >> n;
    if (s == "+")
      data.add(n);
    else if (s == "-")
      data.del(n);
    else
      cout << data.find(n), cout << "\n";
    ;
  }
  return 0;
}

```