Akter wants to develop a ‘Minesweeper’ game like the one below. To do this, let’s first write a program that counts how many mines are placed among the cells adjacent to a cell without mines and outputs that value.
Write a program that, given a minefield, checks the number of mines among neighboring cells (horizontally, vertically, and diagonally adjacent) for cells without mines and outputs that number, and for cells containing mines, outputs the mine shape as is.
Input
First, the number of test cases T (1 <= T <= 10) is input. Next, M and N (3 <= M, N <= 30), representing a minefield of size M x N (M: height, N: width), are input. Then, the M x N minefield is input. Cells without mines are marked with ‘.’, and cells containing mines are marked with ‘*’.
Output
For each test case, output the number of mines in the surrounding cells in an M x N size. Print '*' for the locations where mines are present as usual. Do not print blank lines between the results.