queries-16

We all know about Arvind BR and his amazing skills. He now works in a company. As it is the duty of the seniors to take us out for treat after he/she gets placed, we asked him to treat us. But, his reply was, “I will ask you a question. Write a code which can solve it, and then I will take you out for a treat”. As it is a known fact that we cannot solve questions given by the great BR, we turn to you for help. Write a program to solve his question, and thereby forcing BR to take us out for a treat.

Question Given
    You are given a set of queries of the form,
    1)0 n  -> add the number n to the set
    2)1 n  -> delete the number n from the set
    3)2 q  -> find all the numbers in the set, which give a quotient q, when divided by 2^k, 0 ≤ k ≤ n
        Note: It is not required that k has to be unique for all numbers in the set. You can divide a number by any value of 2^k so that you get the given value as quotient

Input
    The input consists of q, the number of queries.
    Then q lines follow, with each line containing the query.
    Each query contains two numbers, as discussed above.

Output
    Print the required count of all numbers, for the queries of type 3.

Input Constraints
    1 ≤ q ≤ 10^5
    1 ≤ n ≤10^7
            q ≤ 10^7

SAMPLE INPUT
6
0 2
0 5
0 8
0 16
0 32
2 1

SAMPLE OUTPUT
5

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: