#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 1e5 + 5;
const long long int inf = 1e9;
const long double PI = acos(-1);
void yes() {
  cout << "YES";
  cout << "\n";
}
void no() {
  cout << "NO";
  cout << "\n";
}
long long int pmod(long long int a, long long int mod = 1000000007) {
  return ((a) % mod + mod) % mod;
}
long long int cel(long long int x1, long long int y1) {
  if ((x1) <= 0) {
    return (x1) / (y1);
  }
  return (((x1) / (y1)) + (((x1) % (y1)) != 0));
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return ((a / gcd(a, b)) * b);
}
long long bp(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long bpm(long long a, long long b, long long m = 1000000007) {
  if (a >= m) a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    if (res >= m) res %= m;
    a *= a;
    if (a >= m) a %= m;
    b >>= 1;
  }
  if (res >= m) res %= m;
  return res;
}
string vow = "aeiou";
const int dr4[] = {-1, 0, 1, 0};
const int dc4[] = {0, 1, 0, -1};
const int drk[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dck[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int drh[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dch[] = {1, -1, 2, -2, 2, -2, 1, -1};
class node {
 public:
  int cnt;
  node *left;
  node *right;
  node() {
    cnt = 0;
    left = NULL;
    right = NULL;
  }
};
void add(node *n, string k) {
  if (n == NULL) return;
  if (n == NULL) cout << "o";
  (n->cnt)++;
  if (!((k).size())) return;
  if (k[0] == '1') {
    if (n->right == NULL) {
      node *temp = new node();
      n->right = temp;
    }
    add(n->right, k.substr(1));
  } else {
    if (n->left == NULL) {
      node *temp = new node();
      n->left = temp;
    }
    add(n->left, k.substr(1));
  }
}
void rem(node *n, string k) {
  n->cnt--;
  if (!((k).size())) {
    return;
  }
  if (k[0] == '1') {
    rem(n->right, k.substr(1));
    if (n->right->cnt == 0) {
      node *temp = n->right;
      n->right = NULL;
      delete (temp);
    }
  } else {
    rem(n->left, k.substr(1));
    if (n->left->cnt == 0) {
      node *temp = n->left;
      n->left = NULL;
      delete (temp);
    }
  }
}
long long int mx = 0;
void find(node *n, string k) {
  if (!((k).size())) return;
  if (k[0] == '1') {
    if (n->left != NULL) {
      mx = mx * 2 + 1;
      find(n->left, k.substr(1));
    } else {
      mx = mx * 2;
      find(n->right, k.substr(1));
    }
  } else {
    if (n->right != NULL) {
      mx = mx * 2 + 1;
      find(n->right, k.substr(1));
    } else {
      mx = mx * 2;
      find(n->left, k.substr(1));
    }
  }
}
void solve(int tc) {
  node *rt = new node();
  string k;
  for (int i = 0; i < 32; i++) k += '0';
  add(rt, k);
  int q;
  cin >> q;
  while (q--) {
    char t;
    int x;
    cin >> t >> x;
    string k;
    while (x) {
      if (x % 2)
        k += '1';
      else
        k += '0';
      x >>= 1;
    }
    int s = 32 - ((k).size());
    while (s--) k += '0';
    reverse((k).begin(), (k).end());
    if (t == '+')
      add(rt, k);
    else if (t == '-')
      rem(rt, k);
    else {
      mx = 0;
      find(rt, k);
      cout << mx << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  int t = 1;
  for (int i = 1; i < t + 1; i++) {
    solve(i);
    cout << "\n";
  }
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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 long long int maxn = 1e5 + 5;
const long long int inf = 1e9;
const long double PI = acos(-1);
void yes() {
  cout << "YES";
  cout << "\n";
}
void no() {
  cout << "NO";
  cout << "\n";
}
long long int pmod(long long int a, long long int mod = 1000000007) {
  return ((a) % mod + mod) % mod;
}
long long int cel(long long int x1, long long int y1) {
  if ((x1) <= 0) {
    return (x1) / (y1);
  }
  return (((x1) / (y1)) + (((x1) % (y1)) != 0));
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return ((a / gcd(a, b)) * b);
}
long long bp(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long bpm(long long a, long long b, long long m = 1000000007) {
  if (a >= m) a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    if (res >= m) res %= m;
    a *= a;
    if (a >= m) a %= m;
    b >>= 1;
  }
  if (res >= m) res %= m;
  return res;
}
string vow = "aeiou";
const int dr4[] = {-1, 0, 1, 0};
const int dc4[] = {0, 1, 0, -1};
const int drk[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dck[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int drh[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dch[] = {1, -1, 2, -2, 2, -2, 1, -1};
class node {
 public:
  int cnt;
  node *left;
  node *right;
  node() {
    cnt = 0;
    left = NULL;
    right = NULL;
  }
};
void add(node *n, string k) {
  if (n == NULL) return;
  if (n == NULL) cout << "o";
  (n->cnt)++;
  if (!((k).size())) return;
  if (k[0] == '1') {
    if (n->right == NULL) {
      node *temp = new node();
      n->right = temp;
    }
    add(n->right, k.substr(1));
  } else {
    if (n->left == NULL) {
      node *temp = new node();
      n->left = temp;
    }
    add(n->left, k.substr(1));
  }
}
void rem(node *n, string k) {
  n->cnt--;
  if (!((k).size())) {
    return;
  }
  if (k[0] == '1') {
    rem(n->right, k.substr(1));
    if (n->right->cnt == 0) {
      node *temp = n->right;
      n->right = NULL;
      delete (temp);
    }
  } else {
    rem(n->left, k.substr(1));
    if (n->left->cnt == 0) {
      node *temp = n->left;
      n->left = NULL;
      delete (temp);
    }
  }
}
long long int mx = 0;
void find(node *n, string k) {
  if (!((k).size())) return;
  if (k[0] == '1') {
    if (n->left != NULL) {
      mx = mx * 2 + 1;
      find(n->left, k.substr(1));
    } else {
      mx = mx * 2;
      find(n->right, k.substr(1));
    }
  } else {
    if (n->right != NULL) {
      mx = mx * 2 + 1;
      find(n->right, k.substr(1));
    } else {
      mx = mx * 2;
      find(n->left, k.substr(1));
    }
  }
}
void solve(int tc) {
  node *rt = new node();
  string k;
  for (int i = 0; i < 32; i++) k += '0';
  add(rt, k);
  int q;
  cin >> q;
  while (q--) {
    char t;
    int x;
    cin >> t >> x;
    string k;
    while (x) {
      if (x % 2)
        k += '1';
      else
        k += '0';
      x >>= 1;
    }
    int s = 32 - ((k).size());
    while (s--) k += '0';
    reverse((k).begin(), (k).end());
    if (t == '+')
      add(rt, k);
    else if (t == '-')
      rem(rt, k);
    else {
      mx = 0;
      find(rt, k);
      cout << mx << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  int t = 1;
  for (int i = 1; i < t + 1; i++) {
    solve(i);
    cout << "\n";
  }
  return 0;
}

```