L. Locomotive Control Center
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

At station A, there are $$$n$$$ railcars, numbered with distinct values from $$$1$$$ to $$$n$$$, in an arbitrary order. However, the order in which they are in track A is important, as they will leave point A exactly in the order in which they are listed. For example, if $$$n$$$ = 3 and we have the order [2, 3, 1], railcar number 3 can only leave after railcar 1 has departed from point A. Similarly, railcar 2 can only leave after railcars 1 and 3 have departed from the station A.

The $$$n$$$ railcars need to be moved to station C, such that the first railcar to arrive at this location is 1, followed by 2, 3, and so forth up to the last railcar.

To accomplish this, individual railcars can be moved from one station to another in the order indicated by the arrows:

Operation 1Operation 2Operation 3
A to BB to CA to C

Nevertheless, since there is only one track at point B (just like at points A and C), any railcar arriving at B after a railcar $$$p$$$ already arrived (and it's still at point B), it must leave point B before $$$p$$$ to make it possible to move railcar $$$p$$$.

Determine the $$$\bf{shortest}$$$ sequence of operations to move all railcars from station A to station C in the desired order.

Input

The program reads the number $$$n$$$ $$$(1 \leq n \leq 10^5)$$$, and then n distinct natural numbers between $$$1$$$ and $$$n$$$, representing the order of the railcars on track A.

Output

The program will display on the screen the number $$$Q$$$ of operations performed, followed by the $$$Q$$$ operations.

Each operation will be displayed on a separate line of the screen and will consist of two characters in the form $$$T$$$ $$$Z$$$, signifying that a railcar is being moved from station $$$T$$$ to station $$$Z$$$. If it is not possible to move the railcars from station $$$A$$$ to station $$$C$$$, the number of operations displayed will be $$$-1$$$.

Examples
Input
8
8 5 6 4 2 3 1 7
Output
11
A B
A C
A B
A C
B C
A C
A B
A C
B C
B C
A C
Input
5
1 2 3 5 4
Output
-1