Author has gone out of the stories about Vasiliy, so here is just a formal task description.

You are given q queries and a multiset A, initially containing only integer 0. There are three types of queries:

  1. "+ x" — add integer x to multiset A.
  2. "- x" — erase one occurrence of integer x from multiset A. It's guaranteed that at least one x is present in the multiset A before this query.
  3. "? x" — you are given integer x and need to compute the value <image>, i.e. the maximum value of bitwise exclusive OR (also know as XOR) of integer x and some integer y from the multiset A.



Multiset is a set, where equal elements are allowed.

Input

The first line of the input contains a single integer q (1 ≤ q ≤ 200 000) — the number of queries Vasiliy has to perform.

Each of the following q lines of the input contains one of three characters '+', '-' or '?' and an integer xi (1 ≤ xi ≤ 109). It's guaranteed that there is at least one query of the third type.

Note, that the integer 0 will always be present in the set A.

Output

For each query of the type '?' print one integer — the maximum value of bitwise exclusive OR (XOR) of integer xi and some integer from the multiset A.

Example

Input

10
+ 8
+ 9
+ 11
+ 6
+ 1
? 3
- 8
? 3
? 8
? 11


Output

11
10
14
13

Note

After first five operations multiset A contains integers 0, 8, 9, 11, 6 and 1.

The answer for the sixth query is integer <image> — maximum among integers <image>, <image>, <image>, <image> and <image>.
import java.io.*;
import java.util.*;
public class div367Dnew
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	public static void main(String[] args) throws IOException {
		new div367Dnew().run();
	}
	void run() throws IOException {
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve()throws IOException {
		long q=nl();
		Tries trie=new Tries();
		int start=0;
		trie.insert(getbinary(start));
		Hashtable<Integer,Integer> ht=new Hashtable<Integer,Integer>();
		ht.put(0,1);
		while(q-->0) {
			char s=ns().charAt(0);
			if(s=='+')
			{
				int ele=ni();
				if(ht.containsKey(ele)==false) ht.put(ele,1); else ht.put(ele,ht.get(ele)+1);
				trie.insert(getbinary(ele));
			}
			else if(s=='?'){
				int ele=ni();
				ob.println(trie.query(getbinary(ele),ele));
			}
			else if(s=='-'){
				int x=ni();
				Nodes temp=new Nodes();
				if(ht.get(x)==1)
				{
					trie.delete(getbinary(x),0);
					trie.init();
				}
				ht.put(x,ht.get(x)-1);
			}
		}
	}
	char [] getbinary(int x) throws IOException {
		char s[]=Integer.toBinaryString(x).toCharArray();
		int l=s.length;
		char c[]=new char[32];
		for(int i=31,j=l-1;i>=0;i--,j--)
			{
				if(j>=0)
					c[i]=s[j];
				else
					c[i]='0';
			}
			return c;
	}
	String ns() throws IOException {
		return nextToken();
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
}
class Nodes
{	
	Nodes a[]=new Nodes[2];
}
class Tries
{
	Nodes root=new Nodes();
	int f=0;
	void insert(char s[]) {
		Nodes temp=root;
		for (int i=0; i<32 ;i++ ) {
			if(temp.a[s[i]-'0']==null) 
				temp.a[s[i]-'0']=new Nodes();
			temp=temp.a[s[i]-'0'];
		}
	}
	void init() {
		this.f=0;
	}
	void delete(char s[],int i) {
		if(i>=32)
			return;
		if(i<32) {
			delete(s,i+1);
		}
		if(f==0) {
			Nodes temp2=root;
			for(int j=0;j<i;j++)
				temp2=temp2.a[s[j]-'0'];
		
			if(temp2.a[1]!=null && temp2.a[0]!=null)
			{
				temp2.a[s[i]-'0']=null;
				f=1;
			}
			else {
				temp2.a[s[i]-'0']=null;
			}
		}
	}
	int query(char s[],int ele) {
		Nodes temp=root;
		char res[]=new char[32];
		int j=0;
		for (int i=0; i<32; i++) {
			if(s[i]=='0') {
					if(temp.a[1]!=null) {
						res[j++]='1';
						temp=temp.a[1];
					}
					else {
						res[j++]='0';
						temp=temp.a[0];
					}
			}
			else {
					if(temp.a[0]!=null) {
						res[j++]='0';
						temp=temp.a[0];
					}
					else {
						res[j++]='1';
						temp=temp.a[1];
					}
			}
		}
		return Integer.parseInt(new String(res),2)^ele;
	}
}