407711: GYM102878 M Camouflage

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. Camouflagetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Long Long always dreamed of being a cowboy, so he made a robotic cow to ride it for daily driving.

But unfortunately, this robotic cow has not been painted with cow camouflage. Long Long bought paper and paints from the grocery store to make his own cow camouflage.

However, the vicious Master Yi splashed some white paint on the camouflage while Long Long was away, causing many spots on Long Long's cow camouflage.

Poor Long Long has little black paint left. He can only choose to blacken some of the smaller white spot(s) to make his camouflage looking as natural. And Long Long also has a obsession that he will only repaint the white pixel(s) wrapped by black pixel(s), which means after repainting, all the repainted pixels are surrounded by black pixels, while the white pixels outside including the sides and angles will never be repainted. The pixel surrounded is defined as four direction including left, right, up and down.

Input

The first line contains three integers $$$n, m\ (1\le n, m\le 1\ 000)$$$ and $$$d\ (1\le d\le n\times m)$$$ — the height and weight of Long Long's cow camouflage and the spots' area limit that choosed to paint.

The next $$$n$$$ line(s) contain $$$m$$$ character(s) each, where the $$$j$$$-th character of the $$$i$$$-th line is $$$c_{i,j}$$$ ($$$c_{i,j}$$$ is either . if the pixel in $$$(i,j)$$$ is white or # if the pixel in $$$(i,j)$$$ is black).

It is guaranteed that each spot does not cross with any borders.

Output

Plase print $$$n$$$ line(s) with $$$m$$$ character(s) each, which shows the cow camouflage you painted.

ExamplesInput
7 6 5
......
..##..
.#.#..
.#.#..
.#..#.
..##..
......
Output
......
..##..
.###..
.###..
.####.
..##..
......
Input
10 10 3
..........
...##.....
..####....
.##..##...
.######...
.####.....
.#..#.###.
.##.#.#.#.
..###.###.
..........
Output
..........
...##.....
..####....
.######...
.######...
.####.....
.#..#.###.
.##.#.###.
..###.###.
..........

加入题单

算法标签: