#include <bits/stdc++.h>
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll const mod = 1000000007;
template <int span, int scale>
class Trie {
 public:
  template <int node_span>
  class Node {
   public:
    array<Node<node_span>*, node_span> child = {nullptr};
    int count = 0, end = 0;
    char data;
    Node(char c) : data(c){};
  };
  Node<span>* root = new Node<span>(0);
  void insert(string const& s) {
    Node<span>* curr = root;
    for (auto& c : s) {
      int x = c - scale;
      if (curr->child[x] == nullptr) curr->child[x] = new Node<span>(c);
      curr = curr->child[x];
      curr->count++;
    }
    curr->end = 1;
  }
  void erase(string const& s) {
    Node<span>* curr = root;
    for (auto& c : s) {
      int x = c - scale;
      curr = curr->child[x];
      curr->count--;
    }
  }
  ull getbest(string const& s) {
    bitset<32> best;
    best.reset();
    int count = 31;
    Node<span>* curr = root;
    for (auto& c : s) {
      int x = c - scale;
      if (curr->child[x] == nullptr || curr->child[x]->count == 0)
        curr = curr->child[1 - x];
      else
        curr = curr->child[x];
      best[count] = curr->data - scale;
      count--;
    }
    return best.to_ullong();
  }
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  Trie<2, '0'> trie;
  trie.insert("00000000000000000000000000000000");
  int q;
  cin >> q;
  while (q--) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '+') {
      string s;
      for (int i = 31; i >= 0; i--)
        if (x & (1 << i))
          s.push_back('1');
        else
          s.push_back('0');
      trie.insert(s);
    } else if (c == '-') {
      string s;
      for (int i = 31; i >= 0; i--)
        if (x & (1 << i))
          s.push_back('1');
        else
          s.push_back('0');
      trie.erase(s);
    } else {
      string s;
      for (int i = 31; i >= 0; i--)
        if (x & (1 << i))
          s.push_back('0');
        else
          s.push_back('1');
      cout << (trie.getbest(s) ^ x) << '\n';
    }
  }
  return 0;
}
