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

public class Main{
  public static int res = 0;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    StringTokenizer st;
    
    Node trie = new Node();
    res = 0;
    int n = in.nextInt();
    String s = "00000000000000000000000000000000";
    add(trie, s.toCharArray());
    for(int i = 0; i < n; i++)
    {
      char cc = in.next().charAt(0);
      int num = in.nextInt();
      String x = Integer.toBinaryString(num);
      while(x.length() < 32)
        x = "0"+x;
      if(cc == '+')
        add(trie, x.toCharArray());
      else if(cc == '-')
        remove(trie, x.toCharArray());
      else if(cc == '?')
      {
        String ss = search(trie, x.toCharArray());
        int num1 = Integer.parseInt(ss, 2);
        pw.println(num1);
      }
    }
    
    pw.close();
    //System.exit(0);
  }
  static class Node
  {
    public Node[]child;
    public boolean isEnd;
    public int count;
    public Node()
    {
      child = new Node[2];
      isEnd = false;
      count = 0;
    }
  }
  public static void add(Node trie, char[]a)
  {
    for(int i = 0, j = 1; i < 32; i++, j++)
    {
      if(trie.child[a[i]-48] == null)
      {
        trie.child[a[i]-48] = new Node();
      }
      trie = trie.child[a[i]-48];
      trie.count++;
    }
    trie.isEnd = true;
  }
  
  public static String search(Node trie, char[]a)
  {
    String s = "";
    for(int i = 0; i < 32; i++)
    {
      if(trie.child[1^a[i]-48] != null)
      {
        trie = trie.child[1^a[i]-48];
        s+="1";
      }
      else
      {
        s+="0";
        trie = trie.child[a[i]-48];
      }
      
    }
    return s;
  }
  
  public static void remove(Node trie, char[] a)
  {
    for(int i = 0; i < 32; i++)
    {
      if(trie.child[a[i]-48].count <= 1 )
      {
        trie.child[a[i]-48] = null;
        return;
      }
      trie.child[a[i]-48].count--;
      trie = trie.child[a[i]-48];
    }
  }
  
  
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
    
    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }
    
    public String next() {
      
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }
      
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }
    
    public int nextInt() {
      return Integer.parseInt(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }
    
    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }
      
      return true;
      
    }
  }
}