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 Main{
	public static final int mod = 1000000007;
	
	
	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		InputStream input = System.in;
		InputReader in = new InputReader(input);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		Node root = new Node();

		int q = Integer.parseInt(br.readLine());
		
		StringBuilder sb = new StringBuilder("");
		for(int i=0;i<q;i++)
		{
			StringTokenizer st = new StringTokenizer(br.readLine());
			//System.out.println(i+")--------------");
			char x = st.nextToken().charAt(0);
			int y = Integer.parseInt(st.nextToken());
			insert(root,30,0);
			if(x == '+')
			{
				insert(root,30,y);
				
			}
			else if(x == '-')
			{
				delete(root,30,y);
			}
			else 
			{	
				int a = findXOR(root,30, y);
				sb.append(a+"\n");
			}
			
		}
		System.out.println(sb.toString());
	}
	
	public static int findXOR(Node root, int level , int n)
	{	
		//System.out.println(n);
		//System.out.println("level "+level);
		if(level == -1)
			return n;
		
		int bit = (1<<level) & n;
		//System.out.println("bi "+bit);
		if(bit == 0)
		{
			
			if(root.right != null)
			{	//System.out.println("R");
				return findXOR(root.right,level - 1, n|(1<<level));
			}
			else
			{	//System.out.println("L");
				return findXOR(root.left,level - 1,n);
			}
			
		}
		else
		{
			
			if(root.left != null)
			{	//System.out.println("L");
				return findXOR(root.left, level - 1 ,n);
			}
			else
			{	//System.out.println("R");
				return findXOR(root.right, level - 1, n ^ (1<<level));
			}
		}
		
		
		
		
	}
	
	public static void delete(Node root,int level, int n)
	{		
		//System.out.println("level "+level+" "+root);
		if(level == -1)
			{
			root.count--;
			if(root.count == 0)
				root.dead = true;
			return ;
			}
		int bit = (1<<level) & n;
		
		if(bit == 0)
		{
		//	System.out.println("L");
			delete(root.left,level-1,n);
			
			
			
		
			
			
		}
		else
		{
			//System.out.println("R");
			delete(root.right, level-1,n);
			
			
		}
		
		
		if(root.left != null && root.left.dead == true)
			root.left = null;
		if(root.right != null && root.right.dead == true)
			root.right = null;
		
		if(root.left == null && root.right == null)
		{
			root.dead = true;
			
		}
		
		
	}
	public static void insert(Node root,int level, int n)
	{
		
		if(level == -1)
			{
			root.count++;
			return;
			}
		int bit = (1<<level) & n;
		
		if(bit == 0)
		{
			if(root.left == null)
				root.left = new Node();
			insert(root.left,level-1,n);
			
		}
		else
		{
			if(root.right == null)
				root.right = new Node();
			insert(root.right, level-1,n);
			
		}
		
	}
	
	static class Node{
		boolean dead ;
		int count;
		Node left;
		Node right;
		Node()
		{	count = 0;
			dead = false;
			left = null;
			right = null;
		}
		
	}
	
	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while  (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}   