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 Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    class Graph {
        int[][] graph;
        List<Integer>[] temp;
        int n;

        Graph(int n) {
            this.n = n;
            graph = new int[n][];
            temp = createGraphList(n);
        }

        void add(int x, int y) {
            temp[x].add(y);
            temp[y].add(x);
        }

        void addDir(int x, int y) {
            temp[x].add(y);
        }

        void build() {
            for (int i = 0; i < n; i++) {
                graph[i] = new int[temp[i].size()];
                for (int j = 0; j < temp[i].size(); j++) graph[i][j] = temp[i].get(j);
            }
        }

        void buildWithUniq() {
            for (int i = 0; i < n; i++) {
                HashSet<Integer> uniqSet = new HashSet<>();
                uniqSet.addAll(temp[i]);
                graph[i] = new int[uniqSet.size()];
                int index = 0;
                for (int x : uniqSet) {
                    graph[i][index++] = x;
                }
            }
        }
    }

    public static void main(String[] args) {
        new Template().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    class Node {
        Node left;
        Node right;
        int count = 0;

        boolean valid() {
            return count > 0 || left != null || right != null;
        }

        void trim() {
            if (left != null && !left.valid()) left = null;
            if (right != null && !right.valid()) right = null;
        }
    }

    Node head = new Node();

    void add(int x) {
        Node cur = head;
        for (int i = 30; i >= 0; i--) {
            int bit = (x & (1 << i));
            if (bit == 0) {
                if (cur.left == null) cur.left = new Node();
                cur = cur.left;
            } else {
                if (cur.right == null) cur.right = new Node();
                cur = cur.right;
            }
        }
        cur.count++;
    }

    void remove(int x) {
        ArrayDeque<Node> stack = new ArrayDeque<>();
        Node cur = head;
        for (int i = 30; i >= 0; i--) {
            int bit = (x & (1 << i));
            stack.add(cur);
            if (bit == 0) {
                if (cur.left == null) cur.left = new Node();
                cur = cur.left;
            } else {
                if (cur.right == null) cur.right = new Node();
                cur = cur.right;
            }
        }
        cur.count--;
        while (stack.size() > 0) {
            Node c = stack.pollLast();
            c.trim();
        }
    }

    int query(int x) {
        int res = 0;
        Node cur = head;
        for (int i = 30; i >= 0; i--) {
            int bit = (x & (1 << i));
            Node next = bit == 0 ? cur.right : cur.left;
            if (next == null) {
                next = bit == 0 ? cur.left : cur.right;
            } else {
                res |= 1 << i;
            }
            cur = next;
        }
        return res;
    }

    private void solve() {
        int q = readInt();
        add(0);
        while (q -- > 0) {
            char t = readString().charAt(0);
            int x = readInt();
            switch (t) {
                case '+':
                    add(x);
                    break;
                case '-':
                    remove(x);
                    break;
                case '?':
                    out.println(query(x));
                    break;
            }
        }
    }


}