#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  multiset<int> s;
  s.insert(0);
  int q;
  cin >> q;
  while (q--) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '+') {
      s.insert(x);
    } else if (c == '-') {
      s.erase(s.find(x));
    } else {
      int cur = 0;
      for (int i = 30; i >= 0; i--) {
        if (((1 << i) & x) == 0) {
          cur |= (1 << i);
          auto it = s.lower_bound(cur);
          if (it == s.end() || (cur >> i) != (*it >> i)) cur ^= (1 << i);
        } else {
          auto it = s.lower_bound(cur);
          if (it == s.end() || (cur >> i) != (*it >> i)) cur |= (1 << i);
        }
      }
      cout << (x ^ cur) << '\n';
    }
  }
  return 0;
}
