2020 NA Regionals Practice Contest 9

Start

2021-01-30 09:00 AKST

2020 NA Regionals Practice Contest 9

End

2021-01-30 14:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -360 days 20:28:41

5:00:00

0:00:00

Problem LLatin Square

A Latin Square is a $n \cdot n$ array filled with $n$ integers from $1$ to $n$, such that each number appears exactly once in each row and in each column.

For example, below is a Latin Square:

 $1$ $2$ $3$ $2$ $3$ $1$ $3$ $1$ $2$

Gon really likes Latin Squares. He is currently creating one.

Gon first creates an empty matrix with $n$ rows and $n$ columns. Gon then writes $k \cdot n$ numbers in the matrix, using $k$ unique numbers, each appears $n$ times; so that in each row and in each column, no number appears more than once.

However, Gon does not know how to proceed. Please help Gon fills the rest of the Latin square. Of course, you cannot remove any number that Gon wrote. In other words, you can only write on empty cells.

Input

The first line of input contains $2$ integers, $n$ and $k$ $(1 \le n \le 100, 0 \le k \le n)$.

Each of the next $n$ lines contains $n$ integers representing the Latin square. The numbers are between $0$ and $n$, with $0$ representing an empty cell.

It is guaranteed that in each row and in each column, there are no two cells having the same value, and there are exactly $k$ different positive numbers used in the matrix.

Output

If there is no solution, print exactly one line containing ‘NO’.

Otherwise, print ‘YES’, followed by $n$ lines, each containing $n$ numbers — the Latin square.

If there are more than one solution, you can print any one.

Sample Input 1 Sample Output 1
3 1
2 0 0
0 2 0
0 0 2

YES
2 1 3
3 2 1
1 3 2