Stack Sort I
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

There are 3 stacks numbered from 1 to 3. 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 a and b, and pop an integer from the top of the a-th stack, and then push it on the top of the b-th stack. Now your task is to sort the N numbers with no more than 20000 operations. That is to say, after all operations, all the N 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 N integers , denoting the numbers in the first stack from bottom to top. (A_1 is the bottom and A_N is the top)

输出描述:

The first line of output contains an integer M, denoting the number of operations.
In the next M lines, each line contains two integers a and b, denoting an operation. You must guarantee that the a-th stack is not empty when you choose it.
If there are multiple solutions, you can print any one of them.
示例1

输入

复制
2
100 200

输出

复制
4
1 2
1 3
2 1
3 1
示例2

输入

复制
3
200 300 100

输出

复制
6
1 2
1 3
1 2
3 1
2 1
2 1