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 CF706D{ 
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    
    int n = in.nextInt();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    Node trie = new Node();
    add("00000000000000000000000000000000".toCharArray(), trie, 0);
    
    for(int i = 0; i < n; i++){
      char c = in.next().charAt(0);
      int x = in.nextInt();
      String s = Integer.toString(x, 2);
     // System.out.println(c+" "+x+" "+s);
      while(s.length() < 32){
        s = "0"+s;
      }
      
      if(c == '+'){
        int y = 0;
        if(!map.containsKey(x)) map.put(x, y = 1);
        else map.put(x, y = map.get(x)+1);
        if(y == 1) add(s.toCharArray(), trie, x);
      }
      else if(c == '-'){
        int y = 0;
        map.put(x, y = map.get(x)-1);
        if(y == 0) remove(s.toCharArray(), trie, x);
      }
      else{
        long res = getRes(s.toCharArray(), trie);
        pw.println(res);
      }
      
    }
    
    pw.close();
  }
  
  public static long getRes(char[] a, Node trie){
    String s = "";
    
    for(int i = 0; i < 32; i++){
      if(trie.arr[1^(a[i]-48)] != null){
        trie = trie.arr[1^(a[i]-48)];
        s += "1";
      }
      else{
        trie = trie.arr[a[i]-48];
        s += "0";
      }
    }
    return Long.parseLong(s, 2);
  }
  
  public static void remove(char[] a, Node trie, int n){
    for(int i = 0; i < 32; i++){
      if(trie.arr[a[i]-48].count <= 1 ){
        trie.arr[a[i]-48] = null;
        return;
      }
      trie.arr[a[i]-48].count--;
      trie = trie.arr[a[i]-48];
      //if(n == 9) System.err.println(i+" "+trie.count+" "+n+" "+new String(a));
      
    }
  }
        
  
  public static void add(char[] a, Node trie, int n){
     for(int i = 0; i < 32; i++){
       if(trie.arr[a[i]-48] == null){
         trie.arr[a[i]-48] = new Node(a[i]);
       }
       trie = trie.arr[a[i]-48];
       trie.count++;
     }
     trie.isEnd = true;
   }
   
  
  static class Node{
    public Node[] arr;
    public boolean isEnd;
    public int count;
    public Node(char cc){
      arr = new Node[2];
      isEnd = false;
      count = 0;
    }
    public Node(){
      arr = new Node[2];
      isEnd = false;
      count = 0;
    }
  }
  
  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; 
    
    }
  }
}