Colin is studying quantum game theory by watching his two quantum computing chickens, Chi and Ken, play a peculiar seed-picking game. Initially, there are several piles of seeds. The chickens take turns, with Chi moving first. The rules are:
Due to quantum entanglement, the initial pile sizes are uncertain. Colin models this using a multiset $$$S$$$, initially empty. He asks you to support two operations:
Note that $$$S'$$$ may be empty, in which case the first chicken (Chi) loses.
The first line contains an integer $$$n$$$ $$$(1 \le n \le 5 \times 10^5)$$$, the number of operations.
Each of the next $$$n$$$ lines contains three positive integers:
For each type 2 operation, output a line with a single integer: the probability that Chi has a winning strategy, modulo $$$998244353$$$.
61 1 12 1 11 1 12 1 11 2 22 1 2
499122177 499122177 374341633
For the example: