#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAXN = 2e5 + 5;
int a[MAXN * 35][2], cnt[MAXN * 35 * 2], root, top, q;
void Insert(int v, int c) {
  int cur = root;
  for (int i = 31; i >= 0; --i) {
    int x = (v >> i) & 1;
    if (a[cur][x] == 0) a[cur][x] = ++top;
    cur = a[cur][x];
    cnt[cur] += c;
  }
}
int Query(int v) {
  int cur = root, res = 0;
  for (int i = 31; i >= 0; --i) {
    int x = (v >> i) & 1;
    x ^= 1;
    if (a[cur][x] && cnt[a[cur][x]]) {
      res |= (1 << i);
      cur = a[cur][x];
    } else
      cur = a[cur][x ^ 1];
  }
  return res;
}
int main(int argc, char const *argv[]) {
  Insert(0, 1);
  scanf("%d", &q);
  while (q--) {
    char op[10];
    scanf("%s", op);
    if (op[0] == '+') {
      int x;
      scanf("%d", &x);
      Insert(x, 1);
    } else if (op[0] == '-') {
      int x;
      scanf("%d", &x);
      Insert(x, -1);
    } else if (op[0] == '?') {
      int x;
      scanf("%d", &x);
      printf("%d\n", Query(x));
    }
  }
  return 0;
}
