#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1010;
int q;
multiset<int> st;
inline bool yes(int x, int pos) {
  auto p = st.lower_bound(x);
  if (p == st.end()) return 0;
  if (*p >= (x + (1 << pos))) return 0;
  return 1;
}
int main() {
  scanf("%d", &q);
  st.insert(0);
  while (q--) {
    char ch;
    int a;
    scanf(" %c%d", &ch, &a);
    if (ch == '+') {
      st.insert(a);
    } else if (ch == '-') {
      st.erase(st.find(a));
    } else {
      int mn = 0;
      int t = 0;
      for (int i = 30; i >= 0; i--) {
        if ((a & (1 << i)) == 0) {
          t ^= (1 << i);
          if (!yes(t, i)) t ^= (1 << i);
        } else {
          if (!yes(t, i)) t ^= (1 << i);
        }
      }
      printf("%d\n", a ^ t);
    }
  }
}
