#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long q;
  cin >> q;
  char c;
  long long n;
  map<long long, long long> ma;
  ma[0] = 1;
  while (q--) {
    long long res = 0;
    cin >> c >> n;
    if (c == '+') {
      ma[n]++;
    } else if (c == '-') {
      ma[n]--;
      if (ma[n] <= 0) {
        ma.erase(n);
      }
    } else {
      long long res = 0;
      for (int i = 30; i >= 0; i--) {
        long long currbit = 1LL << i;
        long long mask = currbit - 1;
        long long temp = res;
        if (!(n & currbit)) {
          temp = temp | currbit;
        }
        map<long long, long long>::const_iterator it = ma.lower_bound(temp);
        if (it != ma.end() && (it->first & ~mask) == temp)
          res = temp;
        else
          res = temp ^ currbit;
      }
      cout << (res ^ n) << endl;
    }
  }
  return 0;
}
