#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
const int L = 30, N = 1 << L, Q = 2e5 + 10;
struct node {
  int c[2], cnt;
  node() : cnt(0) { memset(c, 0, sizeof c); }
};
node ns[(L + 1) * Q];
int ncnt = 1;
void upd(int x, int v, int i = 1, int bit = L - 1) {
  ns[i].cnt += v;
  if (bit < 0) return;
  int& c = ns[i].c[(x >> bit) & 1];
  if (!c) c = ++ncnt;
  upd(x, v, c, bit - 1);
}
int query(int x, int i = 1, int bit = L - 1) {
  if (bit < 0) return 0;
  int c = ns[i].c[!((x >> bit) & 1)];
  if (ns[c].cnt)
    return query(x, ns[i].c[!((x >> bit) & 1)], bit - 1) ^ (1 << bit);
  return query(x, ns[i].c[(x >> bit) & 1], bit - 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  upd(0, 1);
  int q;
  cin >> q;
  while (q--) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '+') upd(x, 1);
    if (c == '-') upd(x, -1);
    if (c == '?') cout << query(x) << nl;
  }
}
