#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e6 + 7;
int Trie[N][2], children[N][2];
char sign;
bitset<31> num;
int new_node = 1;
void Add(bitset<31> num) {
  int node = 0;
  for (int i = 30; i >= 0; --i) {
    if (children[node][num[i]] == 0) children[node][num[i]] = new_node++;
    ++Trie[node][num[i]];
    node = children[node][num[i]];
  }
}
void Delet(bitset<31> num) {
  int node = 0;
  for (int i = 30; i >= 0; --i) {
    --Trie[node][num[i]];
    if (Trie[node][num[i]] == 0) {
      children[node][num[i]] = 0;
      break;
    }
    node = children[node][num[i]];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  Add(num);
  int n, a;
  cin >> n;
  while (n-- > 0) {
    cin >> sign >> a;
    num = a;
    if (sign == '?') {
      bitset<31> res;
      int node = 0;
      for (int i = 30; i >= 0; --i) {
        if (num[i] == 1) {
          if (children[node][0] != 0) {
            res[i] = 1;
            node = children[node][0];
          } else
            node = children[node][1];
        } else {
          if (children[node][1] != 0) {
            res[i] = 1;
            node = children[node][1];
          } else
            node = children[node][0];
        }
      }
      cout << res.to_ullong() << '\n';
    } else {
      if (sign == '+')
        Add(num);
      else
        Delet(num);
    }
  }
  return 0;
}
