E. Construction Is Not Fun Either
time limit per test
6 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Do you remember the problem "Counting Is Not Fun" from Codeforces Round 1000? Here is a short version of the statement to remind you about it. $$$$$$\rule{500pt}{0.4pt}$$$$$$

A bracket sequence is called balanced if it can be constructed by the following formal grammar.

  1. The empty sequence $$$\varnothing$$$ is balanced.
  2. If the bracket sequence $$$A$$$ is balanced, then $$$\mathtt{(}A\mathtt{)}$$$ is also balanced.
  3. If the bracket sequences $$$A$$$ and $$$B$$$ are balanced, then the concatenated sequence $$$A B$$$ is also balanced.

Given a balanced bracket sequence $$$s$$$, a pair of indices $$$(i,j)$$$ ($$$i \lt j$$$) is called a good pair if $$$s_i$$$ is '(', $$$s_j$$$ is ')', and the two brackets are added simultaneously with respect to Rule 2 while constructing the sequence $$$s$$$. For example, the sequence "(())()" has three different good pairs, which are $$$(1,4)$$$, $$$(2,3)$$$, and $$$(5,6)$$$. One can show that any balanced bracket sequence of $$$2n$$$ brackets contains exactly $$$n$$$ different good pairs, and using any order of rules to construct the same bracket sequence will yield the same set of good pairs.

Emily will play a bracket guessing game with John. The game is played as follows.

Initially, John has a balanced bracket sequence $$$s$$$ containing $$$n$$$ different good pairs, which is not known to Emily. John tells Emily the value of $$$n$$$ and asks Emily to guess the sequence.

Throughout $$$n$$$ turns, John gives Emily the following kind of clue on each turn.

  • $$$l\;r$$$: The sequence $$$s$$$ contains a good pair $$$(l,r)$$$.

The clues that John gives Emily are pairwise distinct and do not contradict each other.

To find out the content of $$$s$$$ as early as possible, Emily wants to know the number of different balanced bracket sequences that match the clues after each turn. Surely, this is not an easy job for Emily, especially when she is given so many good pairs. Now it is your turn to help Emily. Given the clues, you must find the answer before and after each turn. As the answers may be huge, you need to find them modulo $$$998\,244\,353$$$. $$$$$$\rule{500pt}{0.4pt}$$$$$$

Emily's solution was correct, mostly. Well, mostly is an understatement; you should really call it almost always. John realized that it finds the correct answer except for the one case when the answer is $$$x$$$ modulo $$$998\,244\,353$$$.

Given an integer $$$x$$$ ($$$1 \le x \le 998\,244\,352$$$), construct an input to the problem above that satisfies the following conditions.

  • The total number of good pairs, $$$n$$$, is at most $$$2000$$$.
  • There exists some moment before or after a clue, such that the number of different balanced bracket sequences that match the clues equals $$$x$$$ modulo $$$998\,244\,353$$$.

Oh, in case you're wondering, I did reuse the validator for the original problem to prepare this problem. And there's nothing you can do about it! Good luck, people!

Input

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.

The only line of each test case contains a single integer $$$x$$$ ($$$1 \le x \le 998\,244\,352$$$).

Output

On the first line of the test case, output a single integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of good pairs.

Then, on the $$$i$$$-th line of the $$$n$$$ following lines, output two integers $$$l_i$$$ and $$$r_i$$$ representing the $$$i$$$-th clue ($$$1 \le l_i \lt r_i \le 2n$$$).

The clues must be pairwise distinct and must not contradict each other.

Your output must contain some moment before or after a clue, such that the number of different balanced bracket sequences that match the clues equals $$$x$$$ modulo $$$998\,244\,353$$$.

It can be shown that a construction that satisfies all conditions always exists under the constraints of the problem.

Example
Input
2
1
69420
Output
1
1 2
255
1 70
71 136
137 198
199 256
257 298
299 316
317 330
331 340
341 346
347 414
415 466
467 490
491 510
...
Note

On the second test case, you can manually verify that after the $$$13$$$th clue, the number of different balanced bracket sequences that match the clues becomes $$$69\,420$$$ modulo $$$998\,244\,353$$$.

Therefore, the example output satisfies the conditions as long as the full output satisfies the constraint that the clues must be pairwise distinct and must not contradict each other.