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.*;
import java.math.*;


 
public class Main {

    public class TrieNode{

        int k;
        int[] c;
        TrieNode[] n;

        TrieNode(int k){
            this.k = k;
            this.c = new int[2];
            this.n = new TrieNode[2];
        }

        public void add(int x){
            if(k >= 0){



                int node = ((x & 1 << k) == 0) ? 0 : 1;
                if(c[node] == 0){
                    n[node] = new TrieNode(k - 1);
                }
                c[node]++;
            
                //out.println("Adding Number :" + x + " pos " + k + " node " + node +  " c[0] " + c[0] + " c[1]: " + c[1]);
              

                n[node].add(x);
            }
            return;
        }

        public void remove(int x){

            if(k >= 0){
                int node = ((x & 1 << k) == 0) ? 0 : 1;
                c[node]--;
                if(c[node] == 0){
                    n[node] = null;
                }else{
                    n[node].remove(x);
                }
            }

            return;
        }

        public int find(int x){

            if(k >= 0){

                
                int node = ((x & 1 << k) == 0) ? 0 : 1;
                
                if(c[1 - node] != 0){
                    return (1 << k) + n[1 - node].find(x - (node << k));
                }else if(c[node] != 0){
                    return n[node].find(x);
                }else{
                    return x & ((1 << k + 1) - 1);
                }

            }

            return 0;


        }



    }


    public void solve() throws IOException{

        int q = in.nextInt();
        TrieNode t = new TrieNode(29);
        t.add(0);

        for(int i = 1; i <= q; i++){

            String s = in.next();
            int x = in.nextInt();
            
            if(s.equals("+")){

                t.add(x);

            }else if(s.equals("-")){

                t.remove(x);

            }else if(s.equals("?")){

                int num = t.find(x);
                out.println(num);

            }


        }



    }

    public BigInteger gcdBigInt(BigInteger a, BigInteger b){

        if(a.compareTo(BigInteger.valueOf(0L)) == 0){
            return b;
        }else{
            return gcdBigInt(b.mod(a), a);
        }

    }

 
    FastScanner in;
    PrintWriter out;
 
    static class FastScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
 
        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        String nextLine() throws IOException {
            if (st == null || !st.hasMoreTokens())
                return br.readLine();
            StringBuilder result = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) {
                result.append(" ");
                result.append(st.nextToken());
            }
            return result.toString();
        }
 
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
    }
 
    void run() throws IOException {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }
 
    public static void main(String[] args) throws IOException{
        new Main().run();
    }
 
    public void printArr(int[] arr){
        for(int i = 0; i < arr.length; i++){
            out.print(arr[i] + " ");
        }
        out.println();
    }
 
    public long gcd(long a, long b){
        if(a == 0) return b;
        return gcd(b % a, a);
    }

    public boolean isPrime(long num){

        if(num == 0 || num == 1){
            return false;
        }

        for(int i = 2; i * i <= num; i++){
            if(num % i == 0){
                return false;
            }
        }

        return true;
    }

    public class Pair<A, B>{
        public A x; 
        public B y;

        Pair(A x, B y){
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair<?, ?> pair = (Pair<?, ?>) o;
            if (!x.equals(pair.x)) return false;
            return y.equals(pair.y);
        }

        @Override
        public int hashCode() {
            int result = x.hashCode();
            result = 31 * result + y.hashCode();
            return result;
        }

    }

    class Tuple{
        int x; int y; int z;
        Tuple(int ix, int iy, int iz){
            x = ix;
            y = iy;
            z = iz;
        }
    }
}
