World Goes Round

Time Limit: 1 Second    Memory Limit: 32768 KB
Special Judge

World goes round.

World goes round.

World goes round.

Arrange n^2 numbers from 0 to n^2 - 1 into n*n grids. One can rotate a block of 2*2 grids clockwise like in Figure 1. A rotation is denoted by the coordinates of the upper-left corner of the block.


Figure 1: An illustration of rotations

Your task is to rearrange, by a sequence of rotations, all the numbers from 0 to n2 - 1 on the grids in a sorted order from top down, left to right.

Input

The input consists of several test cases. For each case there is a positive integer n (2 <= n <= 10) in the first line, followed by n lines that describe the rows of the board. A test case with n = 0 signals the end of input and must not be processed.

Output

For each case, output in the following format:

K
S1 ... SK

where K is the number of steps taken to accomplish the task, and Si's are the names of the rotations.

If the task cannot be accomplished, simply output "No".

Note: If a solution exists, it will not exceed 10000 steps.

Sample Input

2
0 1
3 2
2
2 0
3 1
3
1 5 2
0 3 8
6 4 7
0

Sample Output

No
3
A0 A0 A0
2
A0 B1
Submit

Source: Zhejiang Provincial Programming Contest 2005