#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
class Trie {
 private:
  struct Node {
    vector<Node*> ar;
    int hatim;
    Node() : hatim(0), ar(2, NULL) {}
  };

 public:
  Node* root;
  Trie() : root(new Node()) {}
  inline void Insert(const int& n, const int& val) {
    Node* cur = root;
    for (int i = 30; i >= 0; i--) {
      int ascii = ison(n, i);
      if (cur->ar[ascii] == NULL) cur->ar[ascii] = new Node();
      cur = cur->ar[ascii];
      cur->hatim += val;
    }
  }
  inline int Search(const int& n, Node* cur, int value = 0, int ans = 0) {
    for (int i = 30; i >= 0; i--) {
      int ascii = !ison(n, i);
      if (cur->ar[ascii] && cur->ar[ascii]->hatim)
        cur = cur->ar[ascii], value += (1 << i);
      else if (cur->ar[!ascii] && cur->ar[!ascii]->hatim)
        cur = cur->ar[!ascii];
      if (cur->hatim) ans = max(ans, value);
    }
    return ans;
  }
} trie;
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int s;
    cin >> c >> s;
    if (c == '+')
      trie.Insert(s, 1);
    else if (c == '-')
      trie.Insert(s, -1);
    else
      cout << max(trie.Search(s, trie.root), s) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
