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 CF367D
{
    private static class Node
    {
        int count;
        Node l,r;
        public Node()
        {
            count=0;
            l=r=null;
        }
    }
    static Node root;
    public static void insert(String s) 
    {
        int i=0,n=s.length();
        Node t=root;
        for(;i<n;i++)
        {
            if(s.charAt(i)=='0')
            {
                if(t.l==null)
                    t.l=new Node();
                t=t.l;
            }
            if(s.charAt(i)=='1')
            {
                if(t.r==null)
                    t.r=new Node();
                t=t.r;
            }
        }
        t.count++;
    }
    public static int query(String s)
    {
        Node t=root;
        int ans=0,i=31;
        while(i>=0)
        {
            if(s.charAt(31-i)=='1')
            {
                if(t.l!=null)
                {
                    ans+=1<<i;
                    t=t.l;
                }
                else
                    t=t.r;
            }
            else
            {
                if(t.r!=null)
                {
                    ans+=1<<i;
                    t=t.r;
                }
                else
                    t=t.l;
            }
            i--;
        }
        return ans;
    }
    public static void delete(String s)
    {
        delete(root,s,0);
    }
    private static boolean delete(Node t,String s, int i) 
    {
        if(i==s.length())
        {
            t.count--;
            return t.count==0;
        }
        Node temp;
        if(s.charAt(i)=='0')
            temp=t.l;
        else
            temp=t.r;
        boolean shouldBeDeleted=delete(temp, s, i+1);
        if(shouldBeDeleted)
        {
            if(s.charAt(i)=='1')
            {
                t.r=null;
                return t.l==null;
            }
            else
            {
                t.l=null;
                return t.r==null;
            }
        }
        return false;
    }
    public static void main(String args[])
    {
        InputReader in = new InputReader(System.in);
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        /*------------------------------My Code starts here------------------------------*/
        int i=0,q=in.nextInt(),n;
        root=new Node();
                        String z="";
                        for(i=0;i<32;i++)
                         z+="0";
                        insert(z);
        String t;
        while(q-->0)
        {
            String[] s=in.nextLine().split(" ");
            t=Integer.toBinaryString(Integer.parseInt(s[1]));
            n=t.length();
            for(i=1;i<=32-n;i++)
                t=new String("0"+t);
            if(s[0].charAt(0)=='+')
            {
                insert(t);
            }
            else if(s[0].charAt(0)=='-')
            {
                delete(t);
            }
            else
            {
                out.println(query(t));
            }
        }
        out.close();
        /*------------------------------The End------------------------------------------*/
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream inputstream) {
            reader = new BufferedReader(new InputStreamReader(inputstream));
            tokenizer = null;
        }

        public String nextLine(){
            String fullLine=null;
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    fullLine=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                return fullLine;
            }
            return fullLine;
        }
        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 long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}