There are

stacks numbered from

to

. Initially, there are
)
integers in the first stack, while the second stack and the third stack are empty. Each time you can choose two stacks

and

, and pop an integer from the top of the

-th stack, and then push it on the top of the

-th stack. Now your task is to sort the

numbers with no more than

operations. That is to say, after all operations, all the

numbers are in the first stack in non-decreasing order from top to bottom.
输入描述:
The first line of input contains an integer
, denoting the number of integers.
The second line contains
integers
, denoting the numbers in the first stack from bottom to top. (
is the bottom and
is the top)
输出描述:
The first line of output contains an integer
, denoting the number of operations.
In the next
lines, each line contains two integers
and
, denoting an operation. You must guarantee that the
-th stack is not empty when you choose it.
If there are multiple solutions, you can print any one of them.
示例2
输出
复制
6
1 2
1 3
1 2
3 1
2 1
2 1