#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double E = exp(1);
template <class T1>
void deb(T1 e) {
  cout << "-->" << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << "-->" << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <typename T>
inline T sqr(T n) {
  return n * n;
}
inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }
template <typename T>
inline T pmod(T n, T m) {
  return ((n % m) + m) % m;
}
template <typename T>
T power(T n, int p) {
  return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));
}
template <typename T>
T bigmod(T n, int p, T m) {
  return (p == 0)
             ? (T)(1)
             : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %
                   m;
}
struct trie {
  int visited;
  int next[2];
  void reset() {
    memset(next, 0, sizeof(next));
    visited = 0;
  }
  int& operator[](int i) { return next[i]; }
};
trie tree[200005 * 30];
int ind;
void insert_in(int n) {
  int p = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    if (tree[p][q] == 0) {
      tree[p][q] = ind++;
      p = tree[p][q];
      tree[p].reset();
      tree[p].visited++;
    } else {
      p = tree[p][q];
      tree[p].visited++;
    }
  }
}
void rmv(int n) {
  int p = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    p = tree[p][q];
    tree[p].visited--;
  }
}
int getmax(int n) {
  int p = 0, ret = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    if (tree[p][!q] != 0 && tree[tree[p][!q]].visited > 0) {
      ret = (ret | (1 << i));
      p = tree[p][!q];
    } else
      p = tree[p][q];
  }
  return ret;
}
int main() {
  int n, num;
  char ch[2];
  while (scanf("%d", &n) == 1) {
    ind = 1;
    tree[0].reset();
    tree[0].visited = 0;
    insert_in(0);
    for (int i = 0; i < n; i++) {
      scanf("%s %d", &ch, &num);
      if (ch[0] == '+') insert_in(num);
      if (ch[0] == '-') rmv(num);
      if (ch[0] == '?') printf("%d\n", getmax(num));
    }
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution 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 double PI = 2.0 * acos(0.0);
const double E = exp(1);
template <class T1>
void deb(T1 e) {
  cout << "-->" << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << "-->" << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <typename T>
inline T sqr(T n) {
  return n * n;
}
inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }
template <typename T>
inline T pmod(T n, T m) {
  return ((n % m) + m) % m;
}
template <typename T>
T power(T n, int p) {
  return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));
}
template <typename T>
T bigmod(T n, int p, T m) {
  return (p == 0)
             ? (T)(1)
             : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %
                   m;
}
struct trie {
  int visited;
  int next[2];
  void reset() {
    memset(next, 0, sizeof(next));
    visited = 0;
  }
  int& operator[](int i) { return next[i]; }
};
trie tree[200005 * 30];
int ind;
void insert_in(int n) {
  int p = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    if (tree[p][q] == 0) {
      tree[p][q] = ind++;
      p = tree[p][q];
      tree[p].reset();
      tree[p].visited++;
    } else {
      p = tree[p][q];
      tree[p].visited++;
    }
  }
}
void rmv(int n) {
  int p = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    p = tree[p][q];
    tree[p].visited--;
  }
}
int getmax(int n) {
  int p = 0, ret = 0;
  for (int i = 30; i >= 0; i--) {
    int q = (n & (1 << i)) > 0;
    if (tree[p][!q] != 0 && tree[tree[p][!q]].visited > 0) {
      ret = (ret | (1 << i));
      p = tree[p][!q];
    } else
      p = tree[p][q];
  }
  return ret;
}
int main() {
  int n, num;
  char ch[2];
  while (scanf("%d", &n) == 1) {
    ind = 1;
    tree[0].reset();
    tree[0].visited = 0;
    insert_in(0);
    for (int i = 0; i < n; i++) {
      scanf("%s %d", &ch, &num);
      if (ch[0] == '+') insert_in(num);
      if (ch[0] == '-') rmv(num);
      if (ch[0] == '?') printf("%d\n", getmax(num));
    }
  }
  return 0;
}

```