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.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	static class Node {
		Node [] children;
		int val;
		
		public Node() {
			this.val = 0;
			this.children = new Node[2];
		}
	}
	static class Trie {
		Node root;
		
		public Trie() {
			this.root = new Node();
			this.root.val = -1;
			Node current = this.root;
			for(int i = 0; i < 30; i++) {
				current.children[0] = new Node();
				current.children[0].val = 1;
				current = current.children[0];
			}
		}
		
		public void add(int num) {
			String bin = Integer.toBinaryString(num);
			int len = bin.length();
			while(len++ < 30) {
				bin = "0"+bin;
			}
			Node current = this.root;
			for(int i = 0; i < 30; i++) {
				byte bit = (byte) (bin.charAt(i) - '0');
				if(current.children[bit] == null) {
					current.children[bit] = new Node();
				}
				current.children[bit].val++;
				current = current.children[bit];
			}
		}
		
		public int maxor(int num) {
			String bin = Integer.toBinaryString(num);
			int len = bin.length();
			String res = "";
			while(len++ < 30) {
				bin = "0"+bin;
			}
			Node current = this.root;
			for(int i = 0; i < 30; i++) {
				byte bit = (byte) (bin.charAt(i) - '0');
				if(current == null) {
					continue;
				}
				if(current.children[bit^1] != null) {
					res += 1;
					current = current.children[bit^1];
				} else {
					res += 0;
					current = current.children[bit];
				}
			}
			return Integer.parseInt(res, 2);
			
		}
		
		public void remove(int num) {
			String bin = Integer.toBinaryString(num);
			int len = bin.length();
			while(len++ < 30) {
				bin = "0"+bin;
			}
			Node current = this.root;
			for(int i = 0; i < 30; i++) {
				byte bit = (byte) (bin.charAt(i) - '0');
				current.children[bit].val--;
				if(current.children[bit].val == 0) {
					current.children[bit] = null;
					return;
				} else {
					current = current.children[bit];
				}
			}
		}
		
		public int maxHeight(Node n) {
			if(n == null) return 0;
			return 1 + Math.max(maxHeight(n.children[0]), maxHeight(n.children[1]));
		}
		
		public void print(Node n, int bit, int level) {
			if(n == null)
				return;
			System.out.println(n.val + " " + bit + " " + level);
			print(n.children[0], 0, level + 1);
			print(n.children[1], 1, level + 1);
		}
		
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st;
		int q = Integer.parseInt(br.readLine());
		Trie t = new Trie();
		while(q-- > 0) {
			st = new StringTokenizer(br.readLine());
			char query = st.nextToken().charAt(0);
			int num = Integer.parseInt(st.nextToken());
			
			switch(query) {
				case '+': {
					t.add(num);
					break;
				}
				case '-': {
					t.remove(num);
					break;
				}
				case '?': {
					pw.println(t.maxor(num));
					break;
				}
			}
		}
		pw.close();
	}
}
