Disk Sort
You are given rods and disks. Initially, each of the first rods contains exactly disks. Each of the disks has one of colors (identified by numbers from to ). Moreover, there are exactly disks of each of the colors. The -th rod is empty.
At each step we can select two rods and such that has at least disk and has at most disks, and move the topmost disk from rod to the top of rod . Note that no rod is allowed to contain more than disks at any time.
Your goal is to sort the disks. More specifically, you have to do a number of operations (potentially ), so that, at the end, each of the first rods contains exactly disks of the same color, and the -th rod is empty.
Find out a solution to sort the disks in at most operations. It can be proven that, under this condition, a solution always exists. If there are multiple solutions, any one is accepted.
Input
The first line contains a positive integer . The next lines contain positive integers each, the color each of the disks initially placed on the rods. The first of the lines indicates the upper row, the second line indicates the middle row, and the third line indicates the lower row.
Output
The first line must contain a non-negative integer , the number of operations. Each of the following lines should contain two distinct numbers , for all , representing the -th operation (as described in the statement).