logo Baltic Olympiad in Informatics
April 30 – May 3, 2010, Tartu, Estonia

Mines (Open Input Task)

Heino drew an HxW grid. Each cell was either empty or contained a mine. Indrek, a good friend of Heino, drew another HxW grid. In each cell of his grid, he wrote the total number of mines in the corresponding cell of Heino's grid and all its adjacent cells (two cells are adjacent if they share a common point). Indrek then erased Heino's grid. Given Indrek's grid, your task is to help Heino restore his original grid.

You may assume that at least one solution always exists.

Input Data

The first line of the input file contains two integers: H (1 ≤ H ≤ 600), the height of the grid, and W (1 ≤ W ≤ 600), the width of the grid. The following H lines each containing W digits describe Indrek's grid.

Output Data

The output file should contain H lines. Each of these lines should contain W characters: 'X' for a mine and '.' for an empty cell.

If there are several correct solutions, submit any one of them.

Example

mines.inmines.out
3 5
24531
46631
34310
.XXX.
.XX..
XX...

Grading

In this task you're given 10 input files named mines.01.in...mines.10.in and as a solution you need to submit corresponding output files. You should not submit a program.

Test data: for Linux (110 KB), for Windows (109 KB).