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.Scanner;
import java.util.HashMap;

public class Main {
    private static int powers[];

    private static class Node {
        private Node[] children = new Node[3];
        private int freq = 0;

        public Node() {

            for (int i = 0; i < 2; i++)
                children[i] = null;
        }
    }

    private static void add(String key, Node node, int numb) {
    
        for (int i = 0; i < key.length(); i++) {
            int index = key.charAt(i) - '0';
            
            if (node.children[index] == null)
                node.children[index] = new Node();

            node.freq++;

            node = node.children[index];
        }
        node.freq++;
    }

    private static void delete(String key, Node node, int numb) {
        
        for (int i = 0; i < key.length(); i++) {
            int elem = key.charAt(i) - '0';
            node.freq--;
            node = node.children[elem];
        }
        node.freq--;
    }

    private static int fas(String key, int i, int sum, Node node) {

        if (i < key.length()) {
            int elem = key.charAt(i) - '0';
            if (elem == 1 && node.children[0] != null && node.children[0].freq > 0) return fas(key, i + 1, (powers[29 - i]) + sum, node.children[0]); 
            if (elem == 0 && node.children[1] != null && node.children[1].freq > 0) return fas(key, i + 1, (powers[29 - i]) + sum, node.children[1]);
            if (node.children[0] != null && node.children[0].freq > 0) return fas(key, i + 1, sum, node.children[0]);
            return fas(key, i + 1, sum, node.children[1]);
        }

        return sum;
    }

    private static String getBinary(int numb) {
        StringBuilder sb = new StringBuilder();
        StringBuilder missing = new StringBuilder();

        while(numb != 0) {
            sb.append(String.valueOf(numb % 2));
            numb /= 2;
        }

        for (int i = 0; i < 30 - sb.toString().length(); i++) missing.append("0");

        return missing.toString() + sb.reverse().toString();
    }

    public static void main(String args[]) {
        powers = new int[31];
        Node root = new Node();
        Scanner in = new Scanner(System.in);
        String zero = Main.getBinary(0);

        Main.add(zero, root, 0);
        powers[0] = 1;
        for (int i = 1; i < 31; i++) powers[i] = 2 << (i - 1);      

        int n = in.nextInt();
        in.nextLine();
        for (int i = 0; i < n; i++) {
            String str = in.nextLine();
            String[] s = str.split(" ");
            Integer val = Integer.valueOf(s[1]);
            String binRep = Main.getBinary(val);
            // System.out.println("Binary " + binRep + " size " + binRep.length() + " numb " + val);
            switch(s[0]) {
                case "+":
                    Main.add(binRep, root, val);
                    break;
                case "-":
                    Main.delete(binRep, root, val);
                    break;
                case "?":
                    System.out.println(Main.fas(binRep, 0, 0, root));
                    break;
                default: break;
            }
        }
    }
}
