using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 6000000 + 10;
const int mod = 1e9 + 7;
char opt[10];
int sz = 1;
struct Node
{
int next[5], hcnt;
Node(){
hcnt=0;
memset(next, 0, sizeof(next));
}
}Trie[maxn];
void _insert(int x)
{
int u=0, pos;
for(int i=30; i>=0; i--){
pos = x&(1<<i)?1:0;
if(Trie[u].next[pos] == 0) Trie[u].next[pos] = sz++;
u = Trie[u].next[pos];
Trie[u].hcnt++;
}
}
void _delete(int x)
{
int u=0, pos;
for(int i=30; i>=0; i--){
pos = x&(1<<i)?1:0;
u = Trie[u].next[pos];
Trie[u].hcnt--;
}
}
void _search(int x)
{
int u=0, pos, res=0, tmp;
for(int i=30; i>=0; i--){
pos = x&(1<<i)?0:1;
tmp = Trie[u].next[pos];
if(tmp && Trie[tmp].hcnt){
res += pow(2, i);
u = tmp;
}
else { u = Trie[u].next[!pos]; }
}
printf("%d\n", res);
}
int main()
{
int q, x;
scanf("%d", &q);
_insert(0);
while(q--){
scanf("%s%d", opt, &x);
if(opt[0] == '+') _insert(x);
else if(opt[0] == '-') _delete(x);
else if(opt[0] == '?') _search(x);
}
}