#include <bits/stdc++.h>
using namespace std;
long long powersof2[34];
struct f_tree {
  struct f_tree* left;
  struct f_tree* right;
  int val;
};
int checkithbit(long long tocheck, int index) {
  return !(!(powersof2[index] & tocheck));
}
struct f_tree* create_ftree() {
  struct f_tree* toReturn = (struct f_tree*)malloc(sizeof(struct f_tree));
  toReturn->left = NULL;
  toReturn->right = NULL;
  toReturn->val = 0;
  return toReturn;
}
void insert(struct f_tree* thetr, long long toIns) {
  struct f_tree* cur = thetr;
  for (int i = 33; i > -1; i--) {
    int res = checkithbit(toIns, i);
    cur->val++;
    if (res) {
      if (cur->right == NULL) cur->right = create_ftree();
      cur = cur->right;
    } else {
      if (cur->left == NULL) cur->left = create_ftree();
      cur = cur->left;
    }
  }
  cur->val++;
  return;
}
void remove(struct f_tree* thetr, long long toDel) {
  struct f_tree* cur = thetr;
  for (int i = 33; i > -1; i--) {
    int res = checkithbit(toDel, i);
    cur->val--;
    if (res)
      cur = cur->right;
    else
      cur = cur->left;
  }
  cur->val--;
  return;
}
long long findMax(struct f_tree* thetr, long long xorer) {
  struct f_tree* cur = thetr;
  long long curnum = 0;
  for (int i = 33; i > -1; i--) {
    int res = checkithbit(xorer, i);
    if (res) {
      if (cur->left != NULL && cur->left->val > 0) {
        curnum = (curnum << 1);
        cur = cur->left;
      } else {
        curnum = (curnum << 1) + 1;
        cur = cur->right;
      }
    } else {
      if (cur->right != NULL && cur->right->val > 0) {
        curnum = (curnum << 1) + 1;
        cur = cur->right;
      } else {
        curnum = curnum << 1;
        cur = cur->left;
      }
    }
  }
  return curnum;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  powersof2[0] = 1;
  for (int i = 1; i < 34; i++) {
    powersof2[i] = powersof2[i - 1] << 1;
  }
  struct f_tree* guru = create_ftree();
  insert(guru, 0);
  for (int i = 0; i < n; i++) {
    char op;
    long long vas;
    cin >> op >> vas;
    if (op == '+')
      insert(guru, vas);
    else if (op == '-')
      remove(guru, vas);
    else {
      long long toPrint = findMax(guru, vas);
      cout << (toPrint ^ vas) << endl;
    }
  }
  return 0;
}
