Magic Square
Numbers from 1 to 9 are written in 3x3 square at arbitrary positions. You can make cyclic shift by one element of some row (to the left or to the right) or column (to the up or to the down). The task is to implement a program, that could find a minimal number of shifts required to transform given square to the magic square.
There is example of such transformation on the picture:
Input
There are three lines in the input file. Each line represents row of the square and consists of three numbers separated by spaces.
Note that any square could be transformed to the magic square with some number of cyclic shifts.
Output
The first line of output file should contain integer n – the minimal number of shift operations required to transform given square to the magic one. First line is followed by n lines, each of them describe single shift. Shifts are encoded in such a way:
Dx – shift down the column x;
Ux – shift up the column x;
Lx – shift left the row x;
Rx – shift right the row x.
Row (column) number x is written after symbols "D", "U", "L" and "R" without space, 1 ≤ x ≤ 3. Rows of the square are numbered from up to down, columns – from left to right.