#include <bits/stdc++.h>
using namespace std;
long long INV2 = 500000004;
long long INV6 = 166666668;
long long power(long long a, long long b, long long c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) x = (x * y) % c;
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};
multiset<int>::iterator it;
int main() {
  int q;
  scanf("%d", &q);
  multiset<int> s;
  s.insert(0);
  char ch;
  int val;
  while (q--) {
    cin >> ch;
    scanf("%d", &val);
    if (ch == '+')
      s.insert(val);
    else if (ch == '-')
      s.erase(s.find(val));
    else {
      long long ans = 0;
      for (int i = 30; i >= 0; --i) {
        int idx = 1 << i;
        if (val & idx) {
          it = s.lower_bound(ans);
          if (it != s.end() && *it & idx) ans |= idx;
        } else {
          long long temp = ans | (1 << i);
          it = s.lower_bound(ans | (1 << i));
          if (it != s.end() && (*it) >> i == temp >> i) ans = temp;
        }
      }
      ans = ans ^ val;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
