#include <bits/stdc++.h>
typedef struct Trie {
  int sum;
  Trie *next[2];
} Trie;
void Delete(Trie *root) {
  if (root->next[0]) Delete(root->next[0]);
  if (root->next[1]) Delete(root->next[1]);
  delete root;
}
void Create(Trie *root, int a, int c) {
  int now, i;
  Trie *p = root;
  for (i = 30; i >= 0; i--) {
    now = 0;
    if (a & (1 << i)) now = 1;
    if (p->next[now] == NULL) {
      Trie *temp = new Trie;
      temp->next[0] = temp->next[1] = NULL;
      temp->sum = 0;
      p->next[now] = temp;
    }
    p = p->next[now];
    p->sum += c;
  }
}
int Query(Trie *root, int k) {
  int now, i, ans = 0;
  Trie *p = root;
  for (i = 30; i >= 0; i--) {
    now = 0;
    if (k & (1 << i)) now = 1;
    if (p->next[now ^ 1] && p->next[now ^ 1]->sum > 0) {
      ans += (1 << i);
      p = p->next[now ^ 1];
    } else
      p = p->next[now];
  }
  return ans;
}
int main(void) {
  int q, a;
  char ch;
  scanf("%d", &q);
  Trie *root = new Trie;
  root->next[0] = root->next[1] = NULL;
  root->sum = 0;
  Create(root, 0, 1);
  while (q--) {
    scanf(" %c%d", &ch, &a);
    if (ch == '+') Create(root, a, 1);
    if (ch == '-') Create(root, a, -1);
    if (ch == '?') printf("%d\n", Query(root, a));
  }
  return 0;
}
