#include <bits/stdc++.h>
using namespace std;
bool b[31];
struct trie {
  trie* nt[2];
  int tot;
  trie() {
    nt[0] = nt[1] = NULL;
    tot = 0;
  }
};
trie* root = new trie();
void insert(trie* cur, int idx) {
  if (idx == -1)
    return;
  else {
    int x = b[idx];
    if (cur->nt[x] == NULL) cur->nt[x] = new trie();
    cur->nt[x]->tot++;
    insert(cur->nt[x], idx - 1);
  }
}
void del(trie* cur, int idx) {
  if (idx == -1)
    return;
  else {
    int x = b[idx];
    del(cur->nt[x], idx - 1);
    cur->nt[x]->tot--;
    if (cur->nt[x]->tot == 0) cur->nt[x] = NULL;
  }
}
int query(trie* cur, int idx) {
  if (idx == -1)
    return 0;
  else {
    int x = 1 - b[idx];
    int add = 1 << idx;
    if (cur->nt[x] == NULL) x = 1 - x, add = 0;
    return query(cur->nt[x], idx - 1) + add;
  }
}
int main() {
  insert(root, 30);
  int q;
  scanf("%d", &q);
  while (q--) {
    char s[2];
    int x;
    scanf("%s%d", s, &x);
    for (int i = 0; i <= 30; i++) {
      b[i] = x % 2;
      x /= 2;
    }
    if (s[0] == '+')
      insert(root, 30);
    else if (s[0] == '-')
      del(root, 30);
    else
      printf("%d\n", query(root, 30));
  }
}
