The game of mines is a tricky one. You start with a grid and you click your way through the cells to find out what's under them. If you click on a cell with a mine under it, it's game over! If you click on a cell without a mine under it, you get to continue. Every time you uncover an empty cell, the cell may show a number indicating the number of mines that are around it in the 8 adjacent cells.
If a cell does not have any mine in its adjacent cells, you will leave the cell unchanged.
The input will start with two integers, and (). The following lines will each contain characters representing the contents of the corresponding cells.
An asterisk (*) is used to indicate a mine and a dot (.) is used indicate an empty cell.
Print the same grid, but with the appropriate numbers in the cells that has mines adjacent to them.
Input | Output |
---|---|
3 9 .**..*... ....*..** ..*...... | 1**22*222 1333*22** .1*211122 |