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.*;

public class D {
  static boolean bit_set(long n, int bit) {
    return ((n>>>bit)&1)==1;
  }
  static class Node {
    int size;
    Node zero;
    Node one;
    public Node() {
      size = 0;
      zero = null;
      one = null;
    }
    public void make_children() {
      if(this.zero == null) {
        this.zero = new Node();
      }
      if(this.one == null) {
        this.one = new Node();
      }
    }
    public void add(long n, int bit) {
      this.size++;
      if(bit == -1) { return; }
      make_children();
      if(bit_set(n, bit)) {
        this.one.add(n, bit-1);
      } else {
        this.zero.add(n, bit-1);
      }
    }
    public void remove(long n, int bit) {
      this.size--;
      if(bit == -1) { return; }
      make_children();
      if(bit_set(n, bit)) {
        this.one.remove(n, bit-1);
      } else {
        this.zero.remove(n, bit-1);
      }
    }
    public long query(long x, int bit, long ans) {
      if(bit == -1) { return ans; }
      make_children();
      assert(this.size > 0);
      assert(this.size == this.zero.size + this.one.size);

      if(bit_set(x, bit)) {
        if(this.zero.size > 0) {
          return this.zero.query(x, bit-1, ans|(1<<bit));
        } else {
          return this.one.query(x, bit-1, ans);
        }
      } else {
        if(this.one.size > 0) {
          return this.one.query(x, bit-1, ans|(1<<bit));
        } else {
          return this.zero.query(x, bit-1, ans);
        }
      }
    }
  }
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Node root = new Node();
    root.add(0, 30);
    int n = in.nextInt();
    for(int i=0; i<n; i++) {
      String typ = in.next();
      long x = in.nextLong();
      if(typ.equals("+")) {
        root.add(x, 30);
      } else if(typ.equals("-")) {
        root.remove(x, 30);
      } else {
        assert(typ.equals("?"));
        System.out.println(root.query(x, 30, 0));
      }
    }
  }
}
