#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30 * 200100;
int q;
int t[MAXN][2];
int cnt[MAXN];
int sz = 1;
void add(int x) {
  int cur = 0;
  for (int i = 29; i > -1; --i) {
    int bit = (x >> i) & 1;
    if (t[cur][bit] == -1) {
      t[cur][bit] = sz++;
    }
    cur = t[cur][bit];
    ++cnt[cur];
  }
}
void remove(int x) {
  int cur = 0;
  for (int i = 29; i > -1; --i) {
    int bit = (x >> i) & 1;
    cur = t[cur][bit];
    --cnt[cur];
  }
}
int ask(int x) {
  int res = 0;
  int cur = 0;
  for (int i = 29; i > -1; --i) {
    int bit = (x >> i) & 1;
    if (t[cur][bit ^ 1] != -1 && cnt[t[cur][bit ^ 1]] > 0) {
      cur = t[cur][bit ^ 1];
      res |= 1 << i;
    } else {
      assert(cnt[t[cur][bit]] > 0);
      cur = t[cur][bit];
    }
  }
  return res;
}
int main() {
  scanf("%d", &q);
  memset(t, 0xff, sizeof t);
  assert(getchar() == '\n');
  add(0);
  for (int i = 0; i < q; ++i) {
    char c;
    int x;
    scanf("%c %d\n", &c, &x);
    if (c == '+') {
      add(x);
    } else if (c == '-') {
      remove(x);
    } else {
      assert(c == '?');
      printf("%d\n", ask(x));
    }
  }
  return 0;
}
