#include <bits/stdc++.h>
using namespace std;
const int CMXS = 30, MAXS = (200000 + 3) * (30 + 3) + 3;
int q, a[3][MAXS], nxt = 0;
bitset<CMXS> b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cin >> q;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < MAXS; j++) a[i][j] = -1;
  for (int i = CMXS - 1, v = 0; (~i ? true : (a[2][v]++, false));
       (~a[b[i]][v] ? v = a[b[i]][v] : v = a[b[i]][v] = ++nxt), i--)
    a[2][v]++;
  while (q--) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '+') {
      b = x;
      for (int i = CMXS - 1, v = 0; (~i ? true : (a[2][v]++, false));
           (~a[b[i]][v] ? v = a[b[i]][v] : v = a[b[i]][v] = ++nxt), i--)
        a[2][v]++;
    }
    if (c == '-') {
      b = x;
      for (int i = CMXS - 1, v = 0; (~i ? true : (a[2][v]--, false));
           v = a[b[i]][v], i--)
        a[2][v]--;
    }
    if (c == '?') {
      b = x;
      bitset<CMXS> f;
      for (int i = CMXS - 1, v = 0; ~i; i--)
        if (~a[1 - b[i]][v] && a[2][a[1 - b[i]][v]] > 0) {
          v = a[1 - b[i]][v];
          f[i] = 1;
        } else
          v = a[b[i]][v];
      cout << f.to_ulong() << '\n';
    }
  }
  return 0;
}
