#include <bits/stdc++.h>
using namespace std;
struct trie {
  int pre;
  trie *a[2];
  trie() {
    pre = 0;
    memset(a, 0, sizeof(a));
  }
};
trie *root = new trie();
int x, bin[32];
char op;
inline void add() {
  trie *p = root;
  for (int i = 31; i >= 0; --i) {
    if (!p->a[bin[i]]) p->a[bin[i]] = new trie;
    p = p->a[bin[i]];
    p->pre++;
  }
}
inline void del() {
  trie *p = root;
  for (int i = 31; i >= 0; --i) {
    p = p->a[bin[i]];
    --p->pre;
  }
}
inline int query() {
  trie *p = root;
  char tmp[32];
  for (int i = 31; i >= 0; --i) {
    if (bin[i] == 1) {
      if (p->a[0] != NULL && p->a[0]->pre)
        tmp[31 - i] = '0', p = p->a[0];
      else
        tmp[31 - i] = '1', p = p->a[1];
    } else {
      if (p->a[1] != NULL && p->a[1]->pre)
        tmp[31 - i] = '1', p = p->a[1];
      else
        tmp[31 - i] = '0', p = p->a[0];
    }
  }
  char *End;
  int ans = strtol(tmp, &End, 2);
  return ans ^ x;
}
int main() {
  add();
  int n;
  cin >> n;
  while (n--) {
    cin >> op >> x;
    int val = x;
    for (int i = 0; i < 32; ++i) bin[i] = val % 2, val /= 2;
    if (op == '+') add();
    if (op == '-') del();
    if (op == '?') cout << query() << '\n';
  }
  return 0;
}
