#arc147b. [arc147_b]Swap to Sort

[arc147_b]Swap to Sort

Problem Statement

You are given a permutation P=(P1,P2,ldots,PN)P=(P_1,P_2,\\ldots,P_N) of (1,2,ldots,N)(1,2,\\ldots,N).

You can repeat the following two kinds of operations in any order to make PP sorted in increasing order.

  • Operation AA: Choose an integer ii such that 1leqileqN11 \\leq i \\leq N-1, and swap PiP_i and Pi+1P_{i+1}.

  • Operation BB: Choose an integer ii such that 1leqileqN21 \\leq i \\leq N-2, and swap PiP_i and Pi+2P_{i+2}.

Find a sequence of operations with the following property:

  • The number of Operations AA is the minimum possible.

  • The total number of operations is not larger than 10510^5.

Under the Constraints of this problem, we can prove that a solution always exists.

Constraints

  • 2leqNleq4002 \\leq N \\leq 400
  • 1leqPileqN,(1leqileqN)1 \\leq P_i \\leq N \\,(1 \\leq i \\leq N)
  • PineqPj,(1leqi<jleqN)P_i \\neq P_j \\,(1 \\leq i < j \\leq N)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN P1P_1 P2P_2 ldots\\ldots PNP_N

Output

Let SS be the number of operations in your answer. Print S+1S+1 lines.

The first line should contain SS.

The (s+1)(s+1)-th (1leqsleqS1 \\leq s \\leq S) line should contain the following:

  • A i if the ss-th operation is Operation AA, and the integer chosen in this operation is ii.

  • B i if the ss-th operation is Operation BB, and the integer chosen in this operation is ii.

If there are multiple solutions satisfying the condition, printing any of them will be accepted.


Sample Input 1

4
3 2 4 1

Sample Output 1

4
A 3
B 1
B 2
B 2

In this Sample Output, PP changes like this: $(3,2,4,1) \\rightarrow (3,2,1,4) \\rightarrow (1,2,3,4) \\rightarrow (1,4,3,2) \\rightarrow (1,2,3,4)$.

Note that you don't have to minimize the total number of operations.


Sample Input 2

3
1 2 3

Sample Output 2

0

Sample Input 3

6
2 1 4 3 6 5

Sample Output 3

3
A 1
A 3
A 5