P7502 "HMOI R1" A Trash Problem with an Unknown Name

Background

Since this is a Honkai Impact 3 round, there should be some background story about Honkai Impact 3 here. However, fz does not play Honkai Impact 3, and he is really lazy, so this problem became a plain statement.

Description

You need to maintain a multiset that supports three operations: 1. Insert a pair of non-negative integers. 1. Delete a pair of non-negative integers. It is guaranteed that this pair is already in the set. 1. Given a pair of non-negative integers $(x,y)$, ask how many pairs $(a,b)$ in the set satisfy $x\operatorname{xor}a>y\operatorname{xor}b$, where $\operatorname{xor}$ denotes the bitwise XOR operation. In this problem, all “pairs” refer to ordered pairs.

Input Format

The first line contains a non-negative integer $M$, representing the number of operations. The next $M$ lines each contain one operation in the following format: - `1 x y` means inserting the pair $(x,y)$. - `2 x y` means deleting the pair $(x,y)$. It is guaranteed that $(x,y)$ appears in the multiset at least once at this moment. - `3 x y` means querying the pair $(x,y)$.

Output Format

Output $M$ lines. For each query, output one line with a non-negative integer, representing the answer to the query.

Explanation/Hint

For the sample, during the first query there are no pairs in the set, so the answer is $0$. During the second query, the set is $\{(3,2),(4,5)\}$. We have $6\operatorname{xor}3=5>0=2\operatorname{xor}2$, and $6\operatorname{xor}4=2