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.IOException;
import java.util.InputMismatchException;

public class VasiliysMultiset {
	public static void main(String[] args) {
		FasterScanner sc = new FasterScanner();

		int Q = sc.nextInt();
		
		StringBuilder sb = new StringBuilder();
		Node root = new Node();
		add(root, 0, 30);
		for (int q = 0; q < Q; q++) {
			char OP = sc.nextString().charAt(0);
			int X = sc.nextInt();
			switch (OP) {
			case '+':
				add(root, X, 30);
				break;
			case '-':
				remove(root, X, 30);
				break;
			case '?':
				sb.append((X ^ bestMatch(root, ~X, 30)) + "\n");
				break;
			}
		}
		System.out.print(sb.toString());
	}
	
	public static void add(Node curr, int num, int bit) {
		if (bit < 0) {
			curr.count++;
			return;
		}
		int idx = (num >> bit) & 1;
		if (curr.next[idx] == null) {
			curr.next[idx] = new Node();
		}
		add(curr.next[idx], num, bit - 1);
	}
	
	public static void remove(Node curr, int num, int bit) {
		if (bit < 0) {
			curr.count--;
			return;
		}
		int idx = (num >> bit) & 1;
		remove(curr.next[idx], num, bit - 1);
		if (curr.next[idx].isDead()) {
			curr.next[idx] = null;
		}
	}
	
	public static int bestMatch(Node curr, int num, int bit) {
		if (bit < 0) {
			return 0;
		}
		int idx = (num >> bit) & 1;
		if (curr.next[idx] == null) {
			idx = 1 - idx;
		}
		return (idx << bit) | bestMatch(curr.next[idx], num, bit - 1);
	}
	
	public static class Node {
		public Node[] next = new Node[2];
		public int count;
		
		public boolean isDead() {
			return count == 0 && next[0] == null && next[1] == null;
		}
	}

	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			return nextIntArray(n, 0);
		}

		public int[] nextIntArray(int n, int off) {
			int[] arr = new int[n + off];
			for (int i = 0; i < n; i++) {
				arr[i + off] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			return nextLongArray(n, 0);
		}

		public long[] nextLongArray(int n, int off) {
			long[] arr = new long[n + off];
			for (int i = 0; i < n; i++) {
				arr[i + off] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}
}