#include <bits/stdc++.h>
using namespace std;
const int MAXBIT = 29;
class node {
 public:
  int count;
  node *n0, *n1;
  node() : count(0), n0(0), n1(0) {}
};
class root {
 public:
  node rn;
  void insert(int x) {
    node *n = &rn;
    n->count++;
    for (int m = 1 << MAXBIT; m > 0; m >>= 1) {
      if (x & m) {
        if (n->n1) {
          n = n->n1;
        } else {
          n = n->n1 = new node;
        }
      } else {
        if (n->n0) {
          n = n->n0;
        } else {
          n = n->n0 = new node;
        }
      }
      n->count++;
    }
  }
  void remove(int x) {
    node *n = &rn;
    n->count--;
    for (int m = 1 << MAXBIT; m > 0; m >>= 1) {
      if (x & m) {
        n = n->n1;
      } else {
        n = n->n0;
      }
      n->count--;
    }
  }
  int maxor(int x) {
    int a = 0;
    node *n = &rn;
    for (int m = 1 << MAXBIT; m > 0; m >>= 1) {
      if (x & m) {
        if (!n->n0) {
          n->n0 = new node;
        }
        if (n->n0->count > 0) {
          n = n->n0;
          a += m;
        } else {
          n = n->n1;
        }
      } else {
        if (!n->n1) {
          n->n1 = new node;
        }
        if (n->n1->count > 0) {
          n = n->n1;
          a += m;
        } else {
          n = n->n0;
        }
      }
    }
    return a;
  }
};
int main(int argc, char **argv) {
  int q;
  cin >> q;
  root r;
  r.insert(0);
  for (int i = 0; i < q; i++) {
    string op;
    int x;
    cin >> op >> x;
    switch (op[0]) {
      case '+':
        r.insert(x);
        break;
      case '-':
        r.remove(x);
        break;
      case '?':
        cout << r.maxor(x) << endl;
        break;
    }
  }
  return 0;
}
