As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.

Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors.

Each warrior is represented by his personality — an integer number pi. Each commander has two characteristics — his personality pj and leadership lj (both are integer numbers). Warrior i respects commander j only if <image> (<image> is the bitwise excluding OR of x and y).

Initially Vova's army is empty. There are three different types of events that can happen with the army:

  * 1 pi — one warrior with personality pi joins Vova's army; 
  * 2 pi — one warrior with personality pi leaves Vova's army; 
  * 3 pi li — Vova tries to hire a commander with personality pi and leadership li. 



For each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire.

Input

The first line contains one integer q (1 ≤ q ≤ 100000) — the number of events.

Then q lines follow. Each line describes the event:

  * 1 pi (1 ≤ pi ≤ 108) — one warrior with personality pi joins Vova's army; 
  * 2 pi (1 ≤ pi ≤ 108) — one warrior with personality pi leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment); 
  * 3 pi li (1 ≤ pi, li ≤ 108) — Vova tries to hire a commander with personality pi and leadership li. There is at least one event of this type. 

Output

For each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event.

Example

Input

5
1 3
1 4
3 6 3
2 4
3 6 3


Output

1
0

Note

In the example the army consists of two warriors with personalities 3 and 4 after first two events. Then Vova tries to hire a commander with personality 6 and leadership 3, and only one warrior respects him (<image>, and 2 < 3, but <image>, and 5 ≥ 3). Then warrior with personality 4 leaves, and when Vova tries to hire that commander again, there are no warriors who respect him.
import java.util.*;
import java.io.*;
public class ChoosingTheCommander {
    
    
    
    /************************ SOLUTION STARTS HERE ************************/
    
    static class BinaryTrie {

        static class Node {
            int size;
            Node zero;
            Node one;
            Node() {
                size = 1;
            }
        }
        Node root;
        static final int offset = 27;  //Maximum index of set bit
        BinaryTrie(){
            root = new Node();
        }

        void insert(int num){
            root = insert(root, num, offset);
        }
        
        int size(Node n) {
            return n == null ? 0 : n.size;
        }
        
        Node insert(Node curr , int num , int idx){
            if(idx < 0) {
                if(curr != null)
                    curr.size++;
                else
                    curr = new Node();
                return curr;
            }
            else{
                if(curr == null)
                    curr = new Node();
                if((num & (1 << idx)) == 0)
                    curr.zero = insert(curr.zero, num, idx - 1);
                else
                    curr.one = insert(curr.one, num, idx - 1);
                
                curr.size = size(curr.zero) + size(curr.one);
                return curr;
            }
        }
        
        void remove(int num){
            remove(root, null, num, offset);
        }
        
        void remove(Node curr , Node parent , int num , int idx){
            if(idx >= 0){
                if((num & (1 << idx)) == 0)
                    remove(curr.zero, curr, num, idx - 1);
                else
                    remove(curr.one, curr, num, idx - 1);
            }
            curr.size--;
        }
        
        int count(Node curr , int a , int b , int idx) {
            if(idx < 0 || curr == null)
                return 0;
            else if((a & (1 << idx)) == 0 && (b & (1 << idx)) == 0)
                return count(curr.zero, a, b, idx - 1);
            else if((a & (1 << idx)) == 0 && (b & (1 << idx)) != 0)
                return size(curr.zero) + count(curr.one, a, b, idx - 1);
            else if((a & (1 << idx)) != 0 && (b & (1 << idx)) == 0)
                return count(curr.one, a, b, idx - 1);
            else
                return size(curr.one) + count(curr.zero, a, b, idx - 1);
        }
        
        int count(int a , int b) {
            return count(root, a, b, offset);
        }
        private StringBuilder toString(StringBuilder prefix, boolean isTail, StringBuilder sb, Node root) {

            if (root == null) {
                sb.append("Tree Empty");
                return sb;
            }

            if (root.zero != null) {
                toString(new StringBuilder().append(prefix).append(isTail ? "│   " : "    "), false, sb, root.zero);
            }
            sb.append(prefix).append(isTail ? "└── " : "┌── ").append(root.size).append("\n");
            if (root.one != null) {
                toString(new StringBuilder().append(prefix).append(isTail ? "    " : "│   "), true, sb, root.one);
            }
            return sb;
        }

        @Override
        public String toString() {
            return this.toString(new StringBuilder(), true, new StringBuilder(), root).toString();
        }
    }
    

    
    private static void solve() {
        
        int Q = nextInt();
        BinaryTrie trie = new BinaryTrie();
        while(Q-->0) {
            switch(nextInt()) {
            case 1:
                trie.insert(nextInt());
                break;
            case 2:
                trie.remove(nextInt());
                break;
            case 3:
                println(trie.count(nextInt(), nextInt()));
                break;
            }
            // println(trie);
        }
        
    }
    
    
    
    /************************ SOLUTION ENDS HERE ************************/
    
    
    
    
    
    /************************ TEMPLATE STARTS HERE **********************/
    
    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        st     = null;
        solve();
        reader.close();
        writer.close();
    }
    
    static BufferedReader reader;
    static PrintWriter    writer;
    static StringTokenizer st;
    
    static String next()
    {while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}            
    st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
    static String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}             
    static int    nextInt()   {return Integer.parseInt(next());}
    static long   nextLong()  {return Long.parseLong(next());}     
    static double nextDouble(){return Double.parseDouble(next());}
    static char   nextChar()  {return next().charAt(0);}
    static int[]  nextIntArray(int n)         {int[] a= new int[n];   int i=0;while(i<n){a[i++]=nextInt();}  return a;}
    static long[] nextLongArray(int n)        {long[]a= new long[n];  int i=0;while(i<n){a[i++]=nextLong();} return a;}    
    static int[]  nextIntArrayOneBased(int n) {int[] a= new int[n+1]; int i=1;while(i<=n){a[i++]=nextInt();} return a;}            
    static long[] nextLongArrayOneBased(int n){long[]a= new long[n+1];int i=1;while(i<=n){a[i++]=nextLong();}return a;}            
    static void   print(Object o)  { writer.print(o);  }
    static void   println(Object o){ writer.println(o);}
    
    /************************ TEMPLATE ENDS HERE ************************/
    
}