시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 256 MB | 0 | 0 | 0 | 0.000% |
Erast Kopi is famous Sudoku puzzle designer. Resounding success of his puzzle compilations caused a number of imitations and plagiarisms. Prior to sending a lawsuit he decided to get more evidence.
Sudoku puzzle is a table 9 × 9, divided into 3 × 3 subtables of 3 × 3 cells each. Each cell may contain a digit from 1 to 9. The task is to fill empty cells with digits in a way that each row, each column and each of the 9 subtables 3 × 3 contains each digit from 1 to 9 exactly once.
Kopi has a database of Sudoku puzzles and he wants to check if it contains similar puzzles. The puzzle P is similar to the puzzle Q, if it is possible to transform the puzzle P into the puzzle Q using a sequence of the following operations:
Help Kopi to find similar puzzles in his database.
The first line of the input contains single integer n — the number of puzzles in the database (1 ≤ n ≤ 20).
The rest of the input contains description of n puzzles: P1, P2, . . . , Pn. Each puzzle is described by nine lines that contain nine characters each. Each character is either a digit from 1 to 9, or a dot (‘.’) denoting an empty cell. An empty line separates consecutive puzzles in the database.
There are no spaces in the input file.
The puzzles are not guaranteed to be solvable.
Check if the puzzle P1 is similar to puzzles P2, P3, . . . , Pn (in this order), than check if the puzzle P2 is similar to puzzles P3, P4, . . . , Pn (in this order) and so on.
If the puzzle Pi is similar to the puzzle Pj (1 ≤ i < j ≤ n) output “Yes”, otherwise output “No”. If the answer is positive, the next line should contain an integer qij — the number of operations required to transform the puzzle Pi to the puzzle Pj . The number of operations is not required to be minimal, however it must not exceed 1000. In the following qij lines write the operations that transform the puzzle Pi to the puzzle Pj , one per line.
Operations are encoded in the following way:
The columns are numbered from left to right and the rows are numbered from top to bottom as they are given in the input file, starting from one.
4 .....1... 1........ .2.....8. ......... 8....9... ......... ....7.... ...2...1. 2...4.... ....2.... ...7.4... 8.......9 .8...2..1 ..2...... ......... ......... ..1.8.... ......... 1........ ......... ......... ......... ......... ......... ......... ......... ......... .....1... 1........ .2.....8. ......... 8....9... ......... ....7.... ...2...1. 2...4....
Yes 7 C 1 2 D 5 3 F r 7 9 c 6 5 C 2 3 D 1 8 No Yes 0 No Yes 8 R 1 2 C 2 3 c 4 5 F r 5 6 c 7 9 D 1 8 D 3 5 No