#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int tot = 0;
int ch[5000001][2];
int s[5000001];
void insert(int x) {
  int Root = 0;
  for (int i = 30; i >= 0; i--) {
    int tmp = (x >> i) & 1;
    if (!ch[Root][tmp]) {
      ch[Root][tmp] = ++tot;
      s[tot] = 0;
    }
    Root = ch[Root][tmp];
    ++s[Root];
  }
}
void del(int x) {
  int Root = 0;
  for (int i = 30; i >= 0; i--) {
    int tmp = (x >> i) & 1;
    Root = ch[Root][tmp];
    --s[Root];
  }
}
int query(int x) {
  int Root = 0, ans = 0;
  for (int i = 30; i >= 0; i--) {
    int tmp = (x >> i) & 1;
    if (s[ch[Root][tmp ^ 1]])
      ans += (1 << i), Root = ch[Root][tmp ^ 1];
    else
      Root = ch[Root][tmp];
  }
  return ans;
}
int q, x;
char str[101];
int main() {
  scanf("%d", &q);
  insert(0);
  while (q--) {
    scanf("%s", str);
    scanf("%d", &x);
    if (str[0] == '+')
      insert(x);
    else if (str[0] == '-')
      del(x);
    else
      printf("%d\n", query(x));
  }
  return 0;
}
