#include <bits/stdc++.h>
using namespace std;
struct node {
  int count;
  node* ch[2];
  node() {
    count = 0;
    ch[0] = ch[1] = NULL;
  }
};
node* trie;
void addNum(string s) {
  node* cur = trie;
  for (int i = 0; i < s.size(); i++) {
    if (cur->ch[s[i] - '0'] == NULL) cur->ch[s[i] - '0'] = new node();
    cur = cur->ch[s[i] - '0'];
    cur->count++;
  }
}
void removeNum(string s) {
  node* cur = trie;
  for (int i = 0; i < s.size(); i++) {
    cur = cur->ch[s[i] - '0'];
    cur->count--;
  }
}
string getMax(string s) {
  node* cur = trie;
  string ret = string(s.size(), '0');
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      if (cur->ch[1] != NULL && cur->ch[1]->count) {
        ret[i] = '1';
        cur = cur->ch[1];
      } else
        cur = cur->ch[0];
    } else {
      if (cur->ch[0] != NULL && cur->ch[0]->count) {
        ret[i] = '1';
        cur = cur->ch[0];
      } else
        cur = cur->ch[1];
    }
  }
  return ret;
}
string intToString(int x) {
  string ret;
  while (x) {
    ret += (char)('0' + x % 2);
    x >>= 1;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
int stringToInt(string s) {
  int ret = 0;
  for (int i = 0; i < s.size(); ++i) {
    ret *= 2;
    if (s[i] == '1') ret++;
  }
  return ret;
}
int q;
char type[200001];
string nums[200001];
int arr[200001];
int maxBits;
int main() {
  while (cin >> q) {
    maxBits = 0;
    for (int i = 0; i < q; i++) {
      cin >> type[i] >> arr[i];
      nums[i] = intToString(arr[i]);
      maxBits = max(maxBits, (int)nums[i].size());
    }
    trie = new node();
    addNum(string(maxBits, '0'));
    for (int i = 0; i < q; ++i) {
      nums[i] = string(maxBits - nums[i].size(), '0') + nums[i];
      if (type[i] == '+') {
        addNum(nums[i]);
      } else if (type[i] == '-') {
        removeNum(nums[i]);
      } else {
        cout << stringToInt(getMax(nums[i])) << '\n';
      }
    }
  }
  return 0;
}
