#P8910. [RC-06] Operation Sequence
[RC-06] Operation Sequence
Problem Description
You are given , and an array of length . Initially, , and .
You may only perform the following type of operation, by printing a specific string:
- Print
i j: where are positive integers with , meaning assign to (i.e., set ).
Please cyclically shift the first elements of array to the right by positions. That is, after all operations you print are executed, it must satisfy:
- For positions , .
- For positions , .
- The -th element can be anything.
You may perform at most assignment operations.
If you use more than operations, you can still get partial points. Specifically, let your number of operations be :
- If , you get points.
- If , you get points.
- If , you get points.
Your score for this problem is the minimum score among all testdata in all test points.
Input Format
This problem contains multiple groups of data in a single test point.
The first line contains the number of data groups .
For each data group:
The first line contains two positive integers .
Output Format
For each data group:
Print the number of operations on the first line. Note that you do not need to minimize .
Then print lines, each containing two positive integers , representing one operation. .
2
3 0
2 1
0
3
3 1
1 2
2 3
Hint
All data satisfy: , , . It is guaranteed that, within the same test point, the sum of all does not exceed .
Translated by ChatGPT 5