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.
/**
 * Created by Aminul on 7/27/2018.
 */

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args)throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        Trie trie = new Trie();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int tp = in.nextInt();
            long x = in.nextLong();

            if(tp == 1){
                trie.add(toBin(x));
            }
            else if(tp == 2) trie.remove(toBin(x));
            else {
                long y = in.nextLong();
                pw.println(trie.query(toBin(x), toBin(y)));
            }
        }


        pw.close();
    }

    static char[] reverseArray(char a[]){
        for(int i = 0, j = a.length-1; i < j; i++, j--){
            char temp = a[i]; a[i] = a[j]; a[j] = temp;
        }
        return a;
    }

    static char[] toBin(long n){
        String s = Long.toBinaryString(n);
        while (s.length() < 64) s = "0"+s;
        return (s.toCharArray());
    }

    static class Node{
        Node left, right;
        int count;
        Node(){

        }

        Node(int c){
            count = c;
        }
    }

    static class Trie{
        Node root;
        char[] s, t;
        void add(char[] s){
           this.s = s;
           add(root, 0);
        }

        Trie() {
            root = new Node();
        }

        void add(Node node, int i){
            node.count++;
            if(i >= s.length) return;
            if(s[i] == '0'){
                if(node.left == null){
                    node.left = new Node();
                }
                add(node.left, i+1);
            }
            else{
                if(node.right == null){
                    node.right = new Node();
                }
                add(node.right, i+1);
            }
        }


        void remove(char[] s){
            this.s = s;
            remove(root, 0);
        }

        void remove(Node node, int i){
            node.count--;
            if(i >= s.length) return;
            if(s[i] == '0'){
                if(node.left == null){
                    node.left = new Node();
                }
                remove(node.left, i+1);
            }
            else{
                if(node.right == null){
                    node.right = new Node();
                }
                remove(node.right, i+1);
            }
        }

        int query(char[]s, char[]t ){
            this.s = s;
            this.t = t;
            return query(root, 0, false);
        }

        int query(Node node, int i, boolean gotSmaller){
            if(gotSmaller && node != null) return node.count;
            if(i >= s.length || node == null) return 0;
            int res = 0;
            int a = s[i] - '0', b = t[i] - '0';
            if( (a ^ 0) < b) res += query(node.left, i+1, true);
            if( (a ^ 1) < b) res += query(node.right, i+1, true);
            if((a ^ 0) == b) res += query(node.left, i+1, false);
            else if((a^1) == b) res += query(node.right, i+1, false);
            return res;
        }
    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;
        static final int ints[] = new int[128];

        public FastReader(InputStream is){
            for(int i='0';i<='9';i++) ints[i]=i-'0';
            this.is = is;
        }

        public int readByte(){
            if(lenbuf == -1)throw new InputMismatchException();
            if(ptrbuf >= lenbuf){
                ptrbuf = 0;
                try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
                if(lenbuf <= 0)return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }
        public int skip() {
            int b;
            while((b = readByte()) != -1 && isSpaceChar(b));
            return b;
        }

        public String next(){
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt(){
            int num = 0, b;
            boolean minus = false;
            while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
            if(b == '-'){
                minus = true;
                b = readByte();
            }

            while(true){
                if(b >= '0' && b <= '9'){
                    num = (num<<3) + (num<<1) + ints[b];
                }else{
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
            if(b == '-'){
                minus = true;
                b = readByte();
            }

            while(true){
                if(b >= '0' && b <= '9'){
                    num = (num<<3) + (num<<1) + ints[b];
                }else{
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
       /* public char nextChar() {
            return (char)skip();
        }*/

        public char[] next(int n){
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while(p < n && !(isSpaceChar(b))){
                buf[p++] = (char)b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        /*private char buff[] = new char[1005];
        public char[] nextCharArray(){
            int b = skip(), p = 0;
            while(!(isSpaceChar(b))){
                buff[p++] = (char)b;
                b = readByte();
            }
            return Arrays.copyOf(buff, p);
        }*/
    }
}