Turjo and Urjo are two exceptionally good brothers. One lazy Friday afternoon, the power went out, leaving them completely bored with nothing to do. To pass the time, Urjo decided to invent a math game to challenge Turjo's calculating speed.
Urjo grabs a piece of paper and writes down two starting numbers, $$$A$$$ and $$$B$$$. He then tells Turjo that he is generating a special sequence. However, since standard addition is way too easy for them, Urjo uses the Bitwise XOR operator ($$$\oplus$$$) to generate the next terms.
Let $$$F$$$ be a sequence. The sequence is defined by Urjo as follows:
$$$$$$F_{1} = A$$$$$$ $$$$$$F_{2} = B$$$$$$ $$$$$$F_{i} = F_{i-1} \oplus F_{i-2} \ for \ all \ i \ge 3$$$$$$
The rules of the game are simple: Urjo will suddenly shout a number $$$N$$$. In order to win the game and prove he is the superior brother, Turjo must instantly shout back the exact value of the $$$N^{th}$$$ term in the sequence defined as $$$F_{N}$$$.
He needs your help to write a lightning-fast program so he can beat his brother and win the game!
Constraints
Input is given in the following format:
| Subtask | Points | Add. constraints |
| $$$1$$$ | $$$5$$$ | $$$N \le 3$$$ |
| $$$2$$$ | $$$7$$$ | $$$A = 1$$$ and $$$B = 1$$$ and $$$N \le 10$$$ |
| $$$3$$$ | $$$8$$$ | $$$N \le 20$$$ |
| $$$4$$$ | $$$10$$$ | $$$N \le 1000$$$ |
| $$$5$$$ | $$$30$$$ | $$$N \le 10^5$$$ |
| $$$6$$$ | $$$40$$$ | No additional constraints |
3 6 7
1
5 9 11
11
Example 1: $$$N=3 \quad A=6 \quad B=7$$$
Example 2: $$$N=5 \quad A=9 \quad B=11$$$
Bitwise XOR ($$$\oplus$$$) compares two numbers in their binary representation. It evaluates each pair of bits according to the following truth table:
| A | B | A $$$\oplus$$$ B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The group chat was once buzzing with messages, reactions, memes and jokes every second just like the peak of every group chat. Alas, the glory days are now over, only Aritro sends messages in the chat now. The others have a life now!
There are $$$N$$$ inactive friends in the chat. Aritro sends messages one by one, and each message is assigned an id equal to the number of messages sent so far, including this message. So his first message has id $$$1$$$, his second has id $$$2$$$, and so on.
A friend can come online at any point. When friend $$$f$$$ comes online, he reads all messages that have been sent so far, and then immediately goes offline. If Aritro sends more messages after that, friend $$$f$$$ will not see them unless he comes online again.
You will be given events in order. Each event is one of the following:
Note: A friend reads message $$$s$$$ if and only if he came online at a time when at least $$$s$$$ messages had already been sent.
Constraints
Input is given in the following format:
Line $$$1$$$: $$$N\ Q$$$
Line $$$1 + i$$$ $$$(1 \le i \le Q)$$$: The $$$i$$$-th query, starting with its type $$$t$$$, represented as one of the following:
For every query of type , print the number of people that have seen the message with id $$$s$$$.
| Group | Add. constraints | Points |
| $$$1$$$ | $$$N = 1$$$ | $$$10$$$ |
| $$$2$$$ | $$$N,Q \le 5000$$$ | $$$20$$$ |
| $$$3$$$ | All type 3 queries appear after all other queries | $$$30$$$ |
| $$$4$$$ | No additional constraints | $$$40$$$ |
4 11112 13 1112 23 12 32 43 4
1 2 3
Query types:
Explanation of the Example:
Through the dark forests, crossing seven seas and thirteen rivers, Pepe has finally reached the mythical Island of Bika. There he found a cave. Some old saying says that whoever finds a cave on the Island of Bika and enters it never comes back alive, but Pepe is known as the most courageous in his village. So, he decides to enter it. There he finds a locked chest and a note beside it. The entrance immediately closes but fortunately Pepe had come with a torch. Pepe starts reading the note:
You are given two positive integers $$$n$$$ and $$$x$$$. There is an array $$$a$$$ consisting of $$$m$$$ non-negative integers. Let $$$m$$$ be the size of the array $$$a$$$. For each $$$i$$$ ($$$1 \le i \le m$$$), $$$a_i$$$ is the base of the $$$i$$$-th summand, and $$$x$$$ is the common exponent of every summand.
Formally,
$$$$$$n = a_1^x + a_2^x + \dots + a_m^x$$$$$$
Your task is to find the minimum possible value of $$$m$$$, i.e. the minimum possible size of $$$a$$$.
Pepe has to enter the answer and the array $$$a$$$ into the chest, which contains a smart lock system. It is said that the Island of Bika was once the greatest in technology.
Help Pepe get the treasure and escape the cave.
Constraints
Subtasks
| Subtask | Points | Add. constraints |
| $$$1$$$ | $$$7$$$ | $$$x=1$$$ |
| $$$2$$$ | $$$8$$$ | $$$2^x \gt n$$$ |
| $$$3$$$ | $$$8$$$ | $$$m=2$$$ |
| $$$4$$$ | $$$10$$$ | $$$x=2;1 \le n \le 100$$$ |
| $$$5$$$ | $$$14$$$ | $$$ 1 \le n \le 1000$$$ |
| $$$6$$$ | $$$25$$$ | $$$ 1 \le n \le 10^5;2\le x \le 3$$$ |
| $$$7$$$ | $$$28$$$ | No additional constraints |
Each test file contains multiple test cases. The first line of the input contains the number of test cases $$$T$$$. Then, for each test case, the input is given in the following format:
For each test case, if it is possible, output the minimum possible value of $$$m$$$ and a sequence of numbers that achieves the answer in the following format:
If it is possible, but you do not output the sequence, output the following:
If there is no possible answer, output the answer in the following format:
465 210 31024 1012 8
2 1 8 3 1 1 2 1 2 12 1 1 1 1 1 1 1 1 1 1 1 1
Example 1
Input
4
65 2
10 3
1024 10
12 8
Partially Correct Output
2 -1
Correct Output
2
1 8
3
1 1 2
1
2
12
1 1 1 1 1 1 1 1 1 1 1 1
Explanation of Example 1: