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.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){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 long l(){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 int i(){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 double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }
    
           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    public static class Trie
    {
        private Trie[] child;        
        private int c;
        
        public Trie() 
        {
            child=new Trie[2];
            c=0;
        }

        public void insert(String s) 
        {
            Trie node = this;
            for(int i=0;i<s.length();i++) 
            {
                int x=s.charAt(i)-'0';
                Trie[] tn=node.getChild();
                if(tn[x]==null)
                tn[x]=new Trie();                    
                
                node=tn[x];
                tn[x].c++;
            }
        }
        
        public void delete(String s)
        {
            Trie node=this;
            for(int i=0;i<s.length();i++) 
            {
                int x=s.charAt(i)-'0';
                Trie[] tn=node.getChild();
                node=tn[x];
                node.c=node.c-1;
            }
        }
        
        public long query(String s)
        {
            Trie node=this;
            long sum=0;
            for(int i=0;i<s.length();i++) 
            {
                int x=s.charAt(i)-'0';
                Trie[] tn=node.getChild();
                x^=1;
                if(tn[x]!=null && tn[x].c>0)
                {
                    sum+=(long)Math.pow(2,31-i);
                    node=tn[x];
                }
                else
                {
                    x^=1;
                    node=tn[x];
                }
            }
            return sum;
        }
        
        public Trie[] getChild()
        {
            return child;
        }

    }
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        Trie trie = new Trie();
        trie.insert("00000000000000000000000000000000");
        HashMap<Integer,Integer> hm=new HashMap<>();
        while(n-->0)
        {
            String s=sc.s();
            int va=sc.i();
            String val=Integer.toBinaryString(va);
            while(val.length()!=32)
            val="0"+val;
            if(s.charAt(0)=='+')
            {
                hm.put(va,hm.getOrDefault(va,0)+1);
                if(hm.get(va)==1)
                trie.insert(val);
            }
            else if(s.charAt(0)=='-')
            {
                hm.put(va,hm.get(va)-1);
                if(hm.get(va)==0)
                trie.delete(val);
            }
            else
            out.println(trie.query(val));
        }
        out.flush();
    }
}