Alice and Bob are big fans of math. In particular, they are
very excited about playing games that are related to numbers.
Whenever they see a puzzle like Sudoku, they cannot stop
themselves from solving it. The objective of Sudoku is to fill
a grid with
digits so that each column, each row, and each of the nine
() subgrids
that compose the grid (also called “boxes”, “blocks”, or
“regions”) contains all of the digits from to . The puzzle setter provides a
partially completed grid, which for a well-posed puzzle has a
single solution.
After many years of solving Sudoku problems, Alice and Bob
are tired of Sudoku. They have been trying to develop a harder
variation of Sudoku, which they are calling Superdoku. In
Superdoku, the grid is bigger – instead of just
. However, the
“block” constraints are impossible to formulate when there are
no further constraints on . Therefore, there are no block
constraints in Superdoku. Instead, the goal is simply to make
sure that each column and each row in the grid contains all of
the integers from to
. After playing for a
while in the standard way (where any of the grid cells may have
previously been filled in), they decide that the game is too
difficult and they want to simplify it. Therefore, they decide
to make the initial grid further constrained. They constrain
the board by filling in the first rows completely.
Alice and Bob both believe that Superdoku is solvable.
However, since could
be very big, it may still take a long time to figure out a
solution. They don’t want to spend too much time on this single
game, so they are asking for your help!
Input
The input consists of a single test case. The first line
lists two space-separated integers and , denoting the size of
the grid and
the number of rows
that are already filled in. Each of the following lines contains space-separated integers, denoting
the first given rows.
All integers in these
lines are between and
.
Output
Output either “yes” or “no” on the first line, indicating if there is a
solution. If there is no solution, do not output anything more.
If there is a solution, output more lines, each containing
space-separated
integers, representing a solution. If there are multiple
solutions, output any one of them.
Sample Input 1 |
Sample Output 1 |
4 2
1 2 3 4
2 3 4 1
|
yes
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
|
Sample Input 2 |
Sample Output 2 |
4 2
1 2 3 4
2 2 2 2
|
no
|