Alice has just created an
-pixel drawing on a digital art program. Each pixel can be coloured in one of
different colours, numbered from
to
, or it can be blank, in which case it will be numbered with
.
After Alice finished the drawing, she decided that it would look better if the edges of the drawing were expanded by
pixels, maintaining colour. More specifically, let a step be a move of one pixel directly up, down, left, or right. If a blank pixel is
or fewer steps away from a coloured pixel, it should take on the colour of that pixel. If multiple pixels are
or fewer steps away, choose the colour of the closest one, and if multiple pixels are equally close, choose the lowest-numbered colour among them.
Please help Alice do this!
Constraints


Subtask 1 [2/15]

Subtask 2 [2/15]


Subtask 3 [3/15]

Subtask 4 [3/15]

Subtask 5 [5/15]
No additional constraints.
Input Specification
The first line contains three space-separated integers,
,
, and
.
The next
lines each contain
space-separated integers: the colour
of each pixel.
Output Specification
Output
lines, each containing
space-separated integers: the drawing after being expanded by
pixels.
Sample Input
Copy
3 10 1
0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 2 2 2 0 0
0 0 0 0 0 0 0 0 0 0
Sample Output
Copy
0 0 1 1 1 2 2 2 0 0
0 1 1 1 1 2 2 2 2 0
0 0 1 1 1 2 2 2 0 0
Comments