#include <bits/stdc++.h>
using namespace std;
struct node {
  node *one, *zero;
  long long cnt;
  node() {
    one = NULL;
    zero = NULL;
    cnt = 0LL;
  }
};
void insert(node *root, long long val, long long inc) {
  long long i, j;
  for (i = 30; i >= 0; i--) {
    long long temp = val & (1LL << i);
    if (temp) {
      if (root->one == NULL) root->one = new node();
      root = root->one;
    } else {
      if (root->zero == NULL) root->zero = new node();
      root = root->zero;
    }
    root->cnt += inc;
  }
}
long long query(node *root, long long num) {
  long long i, j, ans = 0;
  for (i = 30; i >= 0; i--) {
    long long temp = num & (1LL << i);
    if (temp) {
      if (root->zero != NULL && root->zero->cnt > 0) {
        ans += (1LL << i);
        root = root->zero;
      } else
        root = root->one;
    } else {
      if (root->one != NULL && root->one->cnt > 0) {
        ans += (1LL << i);
        root = root->one;
      } else
        root = root->zero;
    }
  }
  return ans;
}
int main() {
  node *root = new node();
  insert(root, 0LL, 1LL);
  long long q;
  cin >> q;
  while (q--) {
    char ch;
    long long val;
    cin >> ch >> val;
    if (ch == '+')
      insert(root, val, 1);
    else if (ch == '-')
      insert(root, val, -1);
    else {
      cout << query(root, val) << endl;
    }
  }
}
