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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.TreeMap;

/**
 * Hello world!
 *
 */
public class App {
    private static TrieNode root = new TrieNode();
    public static void main(String[] args) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            Map<Integer, Integer> cnt = new HashMap<>();
            String[] line;
            line = reader.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            insert(0);
            for (int i = 0; i < n; ++i) {
                line = reader.readLine().split(" ");
                int num = Integer.parseInt(line[1]);
                if (line[0].equals("+")) {
                    insert(num);
                    cnt.put(num, cnt.getOrDefault(num, 0) + 1);
                } else if (line[0].equals("-")) {
                    cnt.put(num, cnt.get(num) - 1);
                    if (cnt.get(num) == 0) {
                        remove(num, 31, root);
                    }
                } else {
                    System.out.println(num ^ findMax(num));
                }
            }
        }
    }

    private static void insert(int num) {
        int shift = Integer.SIZE - 1;
        TrieNode curr = root;
        while (shift >= 0) {
            int currBit = num >> shift & 1;
            if (curr.children[currBit] == null) {
                curr.children[currBit] = new TrieNode();
            }
            curr = curr.children[currBit];
            --shift;
        }
    }

    private static int findMax(int query) {
        int shift = Integer.SIZE - 1;
        TrieNode curr = root;
        int res = 0;
        while (shift >= 0) {
            int currBit = query >> shift & 1;
            if (curr.children[currBit ^ 1] != null) {
                curr = curr.children[currBit ^ 1];
                res = res << 1 | (currBit ^ 1);
            } else {
                curr = curr.children[currBit];
                res = res << 1 | currBit;
            }
            --shift;
        }
        return res;
    }

    private static boolean remove(int num, int shift, TrieNode node) {
        if (node == null || node.children[0] == null && node.children[1] == null) {
            return true;
        }
        int currBit = num >> shift & 1;
        boolean removeNext = remove(num, shift - 1, node.children[currBit]);
        if (removeNext) {
            node.children[currBit] = null;
        }
        return node.children[currBit] == null && node.children[currBit ^ 1] == null;
    }

    private static class TrieNode {
        private TrieNode[] children = new TrieNode[2];
    }
}
