Tudoku#2529

Tudoku

1 second
64 megabytes
Medium

Tom is a master in several mathematical-theoretical disciplines. He recently founded a research lab at our university and teaches newcomers like Jim. In the first lesson, he explained the game of Tudoku to Jim. Tudoku is a straightforward variant of Sudoku because it consists of a board where almost all the numbers are already in place. Such a board is left over when Tom stops solving an ordinary Sudoku, being too lazy to fill in the last few simple cells. Now, you should help Jim solve all the Tudokus Tom left for him.

Sudoku is played on a 9 \times 9 board that is divided into nine different 3 \times 3 blocks. Initially, it contains only a few numbers, and the goal is to fill the remaining cells so that each row, column, and 3 \times 3 block contains every number from to . This can be quite hard, but remember that Tom already filled most cells. A resulting Tudoku board can be solved by repeatedly applying the following rule: if some row, column, or 3 \times 3 block contains exactly eight numbers, fill in the remaining one.

In the following example, three cells are still missing. The upper left cell cannot be determined directly because neither in its row, column, nor block are there eight numbers present. The missing number for the right cell can be determined using the rule above, however, because its column contains exactly eight numbers. Similarly, the number for the lowest free cell can be determined by examining its row. Finally, the last free cell can be filled by looking at its row, column, or block.

Input

The first line contains the number of scenarios. For each scenario, the input contains nine lines of nine digits each. Zeros indicate the cells that have not been filled by Tom and need to be filled by you. Each scenario is terminated by an empty line.

Output

The output for every scenario begins with a line containing "Scenario #:", where is the number of the scenario starting at . Then, print the solved Tudoku board in the same format as the input, except that zeros are replaced with the correct digits. Terminate the output for each scenario with a blank line.

Examples

Example 1

Loading
Loading