#include <bits/stdc++.h>
using namespace std;
unsigned int x, MSB = 1 << 30, IND = 1;
struct Tri {
  bool isZero = false, isOne = false, B = false;
  int zero, one, num = 0;
};
Tri node[10000000];
void change(int add) {
  unsigned int B = MSB, b = MSB << 1, ind = 0;
  while (b) {
    node[ind].num += add;
    if (x & B) {
      if (!node[ind].isOne) {
        node[ind].isOne = true;
        node[IND].B = true;
        node[ind].one = IND++;
      }
      ind = node[ind].one;
    } else {
      if (!node[ind].isZero) {
        node[ind].isZero = true;
        node[IND].B = false;
        node[ind].zero = IND++;
      }
      ind = node[ind].zero;
    }
    B = B >> 1;
    b = b >> 1;
  }
}
int solve() {
  unsigned int B = MSB, b = MSB << 1, ind = 0, num = 0;
  while (b) {
    if (node[ind].B) num++;
    if (x & B) {
      if (node[ind].isZero && node[node[ind].zero].num) {
        ind = node[ind].zero;
      } else {
        ind = node[ind].one;
      }
    } else {
      if (node[ind].isOne && node[node[ind].one].num) {
        ind = node[ind].one;
      } else {
        ind = node[ind].zero;
      }
    }
    B = B >> 1;
    b = b >> 1;
    num = num << 1;
  }
  num = num >> 1;
  return x ^ num;
}
int main() {
  char c;
  int q;
  change(1);
  cin >> q;
  while (q--) {
    cin >> c;
    cin >> x;
    if (c == '+') {
      change(1);
    } else if (c == '-') {
      change(-1);
    } else {
      cout << solve() << endl;
    }
  }
  return 0;
}
