#P1430C. Numbers on Whiteboard
Numbers on Whiteboard
No submission language available for this problem.
Description
Numbers (each integer from to once) are written on a board. In one operation you can erase any two numbers and from the board and write one integer rounded up instead.
You should perform the given operation times and make the resulting number that will be left on the board as small as possible.
For example, if , the following course of action is optimal:
- choose and , so the new number is , and the whiteboard contains ;
- choose and , so the new number is , and the whiteboard contains ;
- choose and , so the new number is , and the whiteboard contains .
It's easy to see that after operations, there will be left only one number. Your goal is to minimize it.
The first line contains one integer () — the number of test cases.
The only line of each test case contains one integer () — the number of integers written on the board initially.
It's guaranteed that the total sum of over test cases doesn't exceed .
For each test case, in the first line, print the minimum possible number left on the board after operations. Each of the next lines should contain two integers — numbers and chosen and erased in each operation.
Input
The first line contains one integer () — the number of test cases.
The only line of each test case contains one integer () — the number of integers written on the board initially.
It's guaranteed that the total sum of over test cases doesn't exceed .
Output
For each test case, in the first line, print the minimum possible number left on the board after operations. Each of the next lines should contain two integers — numbers and chosen and erased in each operation.