eolymp
bolt
Try our new interface for solving problems
Problems

Sudoku

Sudoku

\includegraphics{https://static.e-olymp.com/content/ee/ee5332d11ee827ccb8255e7807846ddab28ede49.jpg} Sudoku is a very simple task. A square table with \textbf{9} rows and \textbf{9} columns is divided to \textbf{9} smaller squares \textbf{3}×\textbf{3} as shown on the Figure. In some of the cells are written decimal digits from \textbf{1} to \textbf{9}. The other cells are empty. The goal is to fill the empty cells with decimal digits from \textbf{1} to \textbf{9}, one digit per cell, in such way that in each row, in each column and in each marked \textbf{3}×\textbf{3} subsquare, all the digits from \textbf{1} to \textbf{9} to appear. Write a program to solve a given Sudoku-task. \InputFile The input data will start with the number of the test cases. For each test case, \textbf{9} lines follow, corresponding to the rows of the table. On each line a string of exactly 9 decimal digits is given, corresponding to the cells in this line. If a cell is empty it is represented by \textbf{0}. \OutputFile For each test case your program should print the solution in the same format as the input data. The empty cells have to be filled according to the rules. If solutions is not unique, then the program may print any one of them. Output data for various test cases separated by blank lines.
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
1
103000509
002109400
000704000
300502006
060000050
700803004
000401000
009205800
804000107
Output example #1
143628579
572139468
986754231
391542786
468917352
725863914
237481695
619275843
854396127