#include <bits/stdc++.h>
using namespace std;
int q;
multiset<int> a;
multiset<int>::iterator it;
bool good(int need, int have, int cntBit) {
  for (int i = 29; i >= cntBit; --i) {
    if (((1 << i) & need) != ((1 << i) & have)) {
      return false;
    }
  }
  return true;
}
int get(int v) {
  int ret = 0;
  for (int i = 29; i >= 0; --i) {
    int need = ((1 << i) & v ? ret : ret ^ (1 << i));
    it = a.lower_bound(need);
    if (it != a.end() && good(need, *it, i)) {
      ret = need;
    } else {
      ret = ((1 << i) & v ? ret ^ (1 << i) : ret);
    }
  }
  return ret;
}
int main() {
  a.insert(0);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    getchar();
    char ty;
    int x;
    ty = getchar();
    scanf("%d", &x);
    if (ty == '+') {
      a.insert(x);
    } else {
      if (ty == '-') {
        a.erase(a.lower_bound(x));
      } else {
        printf("%d\n", get(x) ^ x);
      }
    }
  }
  return 0;
}
