#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9;
multiset<long long> S;
int N;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  S.insert(0);
  for (long long i = 1; i <= N; i++) {
    char c;
    long long x;
    cin >> c >> x;
    if (c == '+') S.insert(x);
    if (c == '-') S.erase(S.find(x));
    if (c == '?') {
      long long ans = 0;
      for (long long i = 30; i >= 0; i--) {
        multiset<long long>::iterator itb =
            S.lower_bound(ans + (((~(x >> i)) & 1LL) << i));
        multiset<long long>::iterator ite =
            S.upper_bound(ans + (((~(x >> i)) & 1LL) << i) + (1LL << i) - 1LL);
        if (itb == ite)
          ans += (((x >> i) & 1LL) << i);
        else
          ans += (((~(x >> i)) & 1LL) << i);
      }
      cout << (x ^ ans) << endl;
    }
  }
  return 0;
}
