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.Arrays;
import java.util.InputMismatchException;
 

public class Fourth {

	static Node root=null;
    public static void main(String[] args) throws Exception
    {
        int n = i();
        root = new Node(2);
        int[] bin1 = new int[32];
    	int num1=1;
    	int x1=0;
    	for( int j=0 ; j<32 ; j++ ){
    		if( (x1&num1)==num1 ){
    			bin1[31-j]=1;
    		}
    		num1 = num1<<1;
    	}
        insert(bin1);
        for( int i=0 ; i<n ; i++ ){
        	char c = s().charAt(0);
        	int x = i();
        	int[] bin = new int[32];
        	int num=1;
        	
        	for( int j=0 ; j<32 ; j++ ){
        		if( (x&num)==num ){
        			bin[31-j]=1;
        		}
        		num = num<<1;
        	}
        	if( c=='+' )
        		insert(bin);
        	else if( c=='-' ){
        		del(bin);
        	}
        	else{
        		int[] ans = new int[32];
        		find(bin,ans);
        		long res=0,pro=1;
        		for( int j=31 ; j>=0 ; j-- ){
        			res+=pro*ans[j];
        			pro*=2L;
        		}
        		out.println(res^x);
        	}
        }
        
        out.close();
        
    }
    
    static void find( int[] bin, int[] ans ){
    	Node trav=root;
    	for( int i=0 ; i<32 ; i++ ){
    		if( bin[i]==0 ){
    			if( trav.right!=null && trav.right.freq>0 ){
    				trav=trav.right;
    				ans[i]=1;
    			}
    			else{
    				trav=trav.left;
    				ans[i]=0;
    			}
    		}
    		else{
    			if( trav.left!=null && trav.left.freq>0 ){
    				trav=trav.left;
    				ans[i]=0;
    			}
    			else{
    				trav=trav.right;
    				ans[i]=1;
    			}
    		}
    	}
    }
    
    static void del( int[] bin ){
    	Node trav=root;
    	for( int i=0 ; i<32 ; i++ ){
    		if( bin[i]==0 )
    			trav=trav.left;
    		else
    			trav=trav.right;
    		trav.freq--;
    		if( trav.freq==0 ){
    			trav.left=null;
    			trav.right=null;
    			return;
    		}
    	}	
    }
    
    static void insert( int[] bin ){
    	Node trav=root;
    	for( int i=0 ; i<32 ; i++ ){
    		if( bin[i]==0 ){
    			if( trav.left==null ){
        			Node nn=new Node(bin[i]);
        			trav.left=nn;
        		}
    			trav=trav.left;
    		}
    		else{
    			if( trav.right==null ){
        			Node nn=new Node(bin[i]);
        			trav.right=nn;
        		}
    			trav=trav.right;
    		}
    		trav.freq++;
    	}
    }
 
    static class Node{
    	int val,freq;
    	Node left,right;
    	
    	public Node( int vall ){
    		val=vall;
    		freq=0;
    	}
    }
    
 	
 	
    static InputReader in = new InputReader(System.in);
    static OutputWriter out = new OutputWriter(System.out);
    
    static int i()
    {
    	return in.readInt();
    }
    
    static long l()
    {
    	return in.readLong();
    }
    
    static double d()
    {
    	return in.readDouble();
    }
    
    static String s()
    {
    	return in.readString();
    }
    
    static void Iarr( int[] array, int no )
    {
    	for( int i=0 ; i<no ; i++ )
    	{
    		array[i] = i(); 
    	}
    }
    
    static void Larr( long[] array, int no )
    {
    	for( int i=0 ; i<no ; i++ )
    	{
    		array[i] = l(); 
    	}
    }
    
    static void Darr( double[] array, int no )
    {
    	for( int i=0 ; i<no ; i++ )
    	{
    		array[i] = d(); 
    	}
    }
    
    static void Sarr( String[] array, int no )
    {
    	for( int i=0 ; i<no ; i++ )
    	{
    		array[i] = s(); 
    	}
    }
    
    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }
 
        
        
        
        
        
        
        public int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int readInt()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public String next()
        {
            return readString();
        }
 
        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
 
    private static class OutputWriter
    {
        private final PrintWriter writer;
 
        public OutputWriter(OutputStream outputStream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
 
        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }
 
        public void print(Object... objects)
        {
            for (int i = 0; i < objects.length; i++)
            {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }
 
        public void println(Object... objects)
        {
            print(objects);
            writer.println();
        }
 
        public void close()
        {
            writer.close();
        }
 
        public void flush()
        {
            writer.flush();
        }
     }
}