#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
inline void write(int x) {
  register char buffor[35];
  register int i = 0;
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
typedef struct K {
  int c = 0, rc = 0;
  struct K *left;
  struct K *right;
} ss;
void insert(ss *head, long long a, long long count) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    if (head->right == NULL) {
      head->right = (ss *)malloc(sizeof(ss));
      head->right->c = 0;
      head->right->rc = 0;
      head->right->right = NULL;
      head->right->left = NULL;
    }
    head->rc += 1;
    insert(head->right, a, count - 1);
  } else {
    if (head->left == NULL) {
      head->left = (ss *)malloc(sizeof(ss));
      head->left->c = 0;
      head->left->rc = 0;
      head->left->right = NULL;
      head->left->left = NULL;
    }
    head->c += 1;
    insert(head->left, a, count - 1);
  }
}
void insert2(ss **head, long long a, long long count) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    (*head)->rc -= 1;
    if ((*head)->rc == 0) {
      (*head)->right = NULL;
      return;
    }
    insert2(&((*head)->right), a, count - 1);
  } else {
    (*head)->c -= 1;
    if ((*head)->c == 0) {
      (*head)->left = NULL;
      return;
    }
    insert2(&((*head)->left), a, count - 1);
  }
}
void recieve(ss *head, long long a, long long count, long long &num) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    if (head->left != NULL)
      recieve(head->left, a, --count, num);
    else {
      num += (long long)pow(2, count);
      recieve(head->right, a, --count, num);
    }
  } else {
    if (head->right != NULL) {
      num += (long long)pow(2, count);
      recieve(head->right, a, --count, num);
    } else
      recieve(head->left, a, --count, num);
  }
}
int main() {
  int t;
  {
    int q;
    ss *x = (ss *)malloc(sizeof(ss));
    x->c = x->rc = 0;
    insert(x, 0, 31);
    scanf("%d", &q);
    char ch;
    int v;
    map<int, int> make_pair;
    while (q--) {
      cin >> ch, scanf("%d", &v);
      if (ch == '+') {
        make_pair[v]++;
        if (make_pair[v] == 1) insert(x, v, 31);
      } else if (ch == '-') {
        make_pair[v]--;
        if (!make_pair[v]) insert2(&x, v, 31);
      } else {
        long long num = 0;
        recieve(x, v, 31, num);
        printf("%lld\n", v ^ num);
      }
    }
  }
  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;
void read(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
inline void write(int x) {
  register char buffor[35];
  register int i = 0;
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
typedef struct K {
  int c = 0, rc = 0;
  struct K *left;
  struct K *right;
} ss;
void insert(ss *head, long long a, long long count) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    if (head->right == NULL) {
      head->right = (ss *)malloc(sizeof(ss));
      head->right->c = 0;
      head->right->rc = 0;
      head->right->right = NULL;
      head->right->left = NULL;
    }
    head->rc += 1;
    insert(head->right, a, count - 1);
  } else {
    if (head->left == NULL) {
      head->left = (ss *)malloc(sizeof(ss));
      head->left->c = 0;
      head->left->rc = 0;
      head->left->right = NULL;
      head->left->left = NULL;
    }
    head->c += 1;
    insert(head->left, a, count - 1);
  }
}
void insert2(ss **head, long long a, long long count) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    (*head)->rc -= 1;
    if ((*head)->rc == 0) {
      (*head)->right = NULL;
      return;
    }
    insert2(&((*head)->right), a, count - 1);
  } else {
    (*head)->c -= 1;
    if ((*head)->c == 0) {
      (*head)->left = NULL;
      return;
    }
    insert2(&((*head)->left), a, count - 1);
  }
}
void recieve(ss *head, long long a, long long count, long long &num) {
  if (count == -1) return;
  if ((a >> count) & 1) {
    if (head->left != NULL)
      recieve(head->left, a, --count, num);
    else {
      num += (long long)pow(2, count);
      recieve(head->right, a, --count, num);
    }
  } else {
    if (head->right != NULL) {
      num += (long long)pow(2, count);
      recieve(head->right, a, --count, num);
    } else
      recieve(head->left, a, --count, num);
  }
}
int main() {
  int t;
  {
    int q;
    ss *x = (ss *)malloc(sizeof(ss));
    x->c = x->rc = 0;
    insert(x, 0, 31);
    scanf("%d", &q);
    char ch;
    int v;
    map<int, int> make_pair;
    while (q--) {
      cin >> ch, scanf("%d", &v);
      if (ch == '+') {
        make_pair[v]++;
        if (make_pair[v] == 1) insert(x, v, 31);
      } else if (ch == '-') {
        make_pair[v]--;
        if (!make_pair[v]) insert2(&x, v, 31);
      } else {
        long long num = 0;
        recieve(x, v, 31, num);
        printf("%lld\n", v ^ num);
      }
    }
  }
  return 0;
}

```