#include <bits/stdc++.h>
using namespace std;
const long long INF = 99999999999999;
const int inf = 999999999;
int Q;
struct node {
  node *next[2];
  int cnt;
  node() {
    memset(next, 0, sizeof(next));
    cnt = 0;
  }
};
long long ans = 0;
node *p, *root;
void _insert(int x) {
  p = root;
  for (int i = 30; i >= 0; i--) {
    int t = (1 & (x >> i)) ? 1 : 0;
    if (p->next[t] == 0) p->next[t] = new node();
    p = p->next[t];
    p->cnt++;
  }
}
void _delete(int x) {
  p = root;
  for (int i = 30; i >= 0; i--) {
    int t = (1 & (x >> i)) ? 1 : 0;
    p = p->next[t];
    p->cnt--;
  }
}
void _query(int x) {
  p = root;
  ans = 0;
  for (int i = 30; i >= 0; i--) {
    int t = (1 & (x >> i)) ? 0 : 1;
    if (p->next[t] != 0 && p->next[t]->cnt) {
      ans += pow(2, i);
      p = p->next[t];
    } else
      p = p->next[!t];
  }
  printf("%lld\n", ans);
}
int main() {
  while (scanf("%d", &Q) == 1) {
    root = new node();
    _insert(0);
    while (Q--) {
      char op;
      int x;
      getchar();
      scanf("%c%d", &op, &x);
      if (op == '+')
        _insert(x);
      else if (op == '-')
        _delete(x);
      else if (op == '?')
        _query(x);
    }
  }
  return 0;
}
