Minesweeper

Time limit1sMemory limit128 MB

Problem

Agent Yeseul has been assigned to survey how many mines are hidden in a minefield. The minefield is a grid of $R \times C$ cells; each cell either contains a mine (the character *) or is empty (the character .).

For every empty cell, Yeseul must count and record the number of mines in the cells adjacent to it. Two cells are considered adjacent if they share an edge or a corner, so each cell is adjacent to at most eight cells (up, down, left, right, and the four diagonals).

Given the layout of the minefield, output the grid with every empty cell replaced by the number of mines adjacent to it.

Input

The input consists of several test cases.

The first line of each test case contains two integers $R$ and $C$ ($1 \le R, C \le 100$), the number of rows and columns of the grid.

Each of the next $R$ lines contains $C$ characters. Each character is either * for a mine or . for an empty cell.

The input ends with a line containing two zeros (0 0).

Output

For each test case, output $R$ lines of $C$ characters. Replace every . with the number of mines adjacent to that cell, and print every * unchanged.

Do not put spaces between characters and do not print blank lines between rows.