#include <bits/stdc++.h>
using namespace std;
struct node {
  node* zero;
  node* one;
  int leafCnt;
};
node* root;
node* getnode() {
  node* newnode = new node;
  newnode->leafCnt = 0;
  newnode->zero = NULL;
  newnode->one = NULL;
  return newnode;
}
void insert(int x) {
  node* temp = root;
  int i = 30, bit;
  while (i >= 0) {
    bit = (x & (1 << i));
    if (bit && temp->one == NULL) temp->one = getnode();
    if (!bit && temp->zero == NULL) temp->zero = getnode();
    if (bit)
      temp = temp->one;
    else
      temp = temp->zero;
    x -= bit;
    i--;
  }
  temp->leafCnt++;
}
void freetree(node* temp) {
  if (temp == NULL) return;
  freetree(temp->one);
  freetree(temp->zero);
  delete temp;
}
void remove(int x) {
  node* temp = root;
  node *lastLeaf = root, *removeNode, *tnode;
  int i = 30, bit, tx, ti;
  while (i >= 0) {
    bit = (x & (1 << i));
    if ((bit && temp->zero != NULL) || (!bit && temp->one != NULL)) {
      lastLeaf = temp;
      tx = x;
      ti = i;
    }
    if (bit)
      temp = temp->one;
    else
      temp = temp->zero;
    x -= bit;
    i--;
  }
  temp->leafCnt--;
  if (!(temp->leafCnt) && (temp->one == NULL) && (temp->zero == NULL)) {
    bit = (tx & (1 << ti));
    if (bit) {
      removeNode = lastLeaf->one;
      lastLeaf->one = NULL;
    } else {
      removeNode = lastLeaf->zero;
      lastLeaf->zero = NULL;
    }
    freetree(removeNode);
  }
}
int maxor(int x) {
  int bit, i = 30, ans = 0;
  node* temp = root;
  while (temp != NULL) {
    bit = x & (1 << i);
    if (!bit && temp->one != NULL) {
      temp = temp->one;
      ans += 1 << i;
    } else if (!bit) {
      temp = temp->zero;
    } else if (temp->zero != NULL) {
      temp = temp->zero;
      ans += 1 << i;
    } else {
      temp = temp->one;
    }
    if (temp != NULL) {
      i--;
      x -= bit;
    }
  }
  return ans + x;
}
int main() {
  int q, x;
  char c;
  cin >> q;
  root = getnode();
  insert(0);
  while (q--) {
    cin >> c >> x;
    if (c == '+') {
      insert(x);
    } else if (c == '-') {
      remove(x);
    } else {
      cout << maxor(x) << endl;
    }
  }
  return 0;
}
