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.BigInteger;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class D extends PrintWriter {

    class Node {
        Node zro, one;
        int cnt;
        final int level;

        public Node(int level) {
            this.level = level;
        }

        boolean test(int integer, int bit) {
            return (integer & (1 << bit)) > 0;
        }

        void add(int x) {
            ++cnt;
            if (level < 0) {
                return;
            }

            if (test(x, level)) {
                if (one == null) {
                    one = new Node(level - 1);
                }
                one.add(x);
            } else {
                if (zro == null) {
                    zro = new Node(level - 1);
                }
                zro.add(x);
            }
        }

        void remove(int x) {
            --cnt;
            if (level < 0) {
                return;
            }

            if (test(x, level)) {
                if (one != null) {
                    one.remove(x);
                }
            } else {
                if (zro != null) {
                    zro.remove(x);
                }
            }
        }

        int maxXor(int x) {
            if (level < 0) {
                return 0;
            }

            if (test(x, level)) {
                if (zro != null && zro.cnt > 0) {
                    return (1 << level) | zro.maxXor(x);
                }
                if (one != null && one.cnt > 0) {
                    return one.maxXor(x);
                }
            } else {
                if (one != null && one.cnt > 0) {
                    return (1 << level) | one.maxXor(x);
                }
                if (zro != null && zro.cnt > 0) {
                    return zro.maxXor(x);
                }
            }

            return 0;
        }
    }

    void run() {
        int q = nextInt();

        Node root = new Node(30);
        root.add(0);

        while (--q >= 0) {
            String t = next();

            int x = nextInt();

            if (t.equals("+")) {
                root.add(x);
            }
            if (t.equals("-")) {
                root.remove(x);
            }
            if (t.equals("?")) {
                println(root.maxXor(x));
            }

        }

    }

    void skip() {
        while (hasNext()) {
            next();
        }
    }

    int[][] nextMatrix(int n, int m) {
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                matrix[i][j] = nextInt();
        return matrix;
    }

    String next() {
        while (!tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(nextLine());
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (!tokenizer.hasMoreTokens()) {
            String line = nextLine();
            if (line == null) {
                return false;
            }
            tokenizer = new StringTokenizer(line);
        }
        return true;
    }

    int[] nextArray(int n) {
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException err) {
            return null;
        }
    }

    public D(OutputStream outputStream) {
        super(outputStream);
    }

    static BufferedReader reader;
    static StringTokenizer tokenizer = new StringTokenizer("");
    static Random rnd = new Random();
    static boolean OJ;

    public static void main(String[] args) throws IOException {
        OJ = System.getProperty("ONLINE_JUDGE") != null;
        D solution = new D(System.out);
        if (OJ) {
            reader = new BufferedReader(new InputStreamReader(System.in));
            solution.run();
        } else {
            reader = new BufferedReader(new FileReader(new File(D.class.getName() + ".txt")));
            long timeout = System.currentTimeMillis();
            while (solution.hasNext()) {
                solution.run();
                solution.println();
                solution.println("----------------------------------");
            }
            solution.println("time: " + (System.currentTimeMillis() - timeout));
        }
        solution.close();
        reader.close();
    }
}