~cpp
// Minesweeper
// UVa ID : 10189
// 2차원 배열에 데이터 입력은 (1,1) 부터 시작한다.
#include <iostream>
//#include <fstream>
using namespace std;
#define ArSize 102
void process(char data[][ArSize], int row, int col);
void init_array(char data[][ArSize], int row, int col);
void output(char data[][ArSize], int row, int col);
//ifstream fin("input.txt");
int main()
{
	char data[ArSize][ArSize];
	int inputRow, inputCol;
	int outputNumber = 1;
	int i, j;
	
	while (cin >> inputRow >> inputCol)
	{
		// 종료조건
		if ((inputRow == 0) && (inputCol == 0))
			break;
		// 배열 초기화 (경계값까지 '.'으로 초기화)
		init_array(data, inputRow + 1, inputCol + 1);
		// 입력 (1,1)이 맨 처음이다.
		for (i = 1; i <= inputRow; i++)
		{
			for (j = 1; j <= inputCol; j++)
			{
				cin >> data[i][j];
			}
		}
		// 지뢰 찾기 작업
		process(data, inputRow, inputCol);
		// 출력 (출력이 하나인 경우는 밑에 빈칸을 두지 않는다!!)
		if (outputNumber > 1)
			cout << endl;
		cout << "Field #" << outputNumber++ << ":" << endl;
		output(data, inputRow, inputCol);
	}
	return 0;
}
void process(char data[][ArSize], int row, int col)
{
	int i, j;
	char count = '0';
	
	for (i = 1; i <= row; i++)
	{
		for (j = 1; j <= col; j++)
		{
			// 지뢰는 pass
			if (data[i][j] == '*')
				continue;
			else
			{
				// 북서
				if (data[i - 1][j - 1] == '*')
					count++;
				// 북
				if (data[i - 1][j] == '*')
					count++;
				// 북동
				if (data[i - 1][j + 1] == '*')
					count++;
				// 동
				if (data[i][j + 1] == '*')
					count++;
				// 동남
				if (data[i + 1][j + 1] == '*')
					count++;
				// 남
				if (data[i + 1][j] == '*')
					count++;
				// 남서
				if (data[i + 1][j - 1] == '*')
					count++;
				// 서
				if (data[i][j - 1] == '*')
					count++;
				data[i][j] = count;
				count = '0';
			}
		}
	}
}
// 배열 초기화
void init_array(char data[][ArSize], int row, int col)
{
	int i, j;
	
	for (i = 0; i <= row; i++)
	{
		for (j = 0; j <= col; j++)
		{
			data[i][j] = '.';
		}
	}
}
// 출력 - 배열 내용 출력
void output(char data[][ArSize], int row, int col)
{
	int i, j;
	
	for (i = 1; i <= row; i++)
	{
		for (j = 1; j <= col; j++)
		{
			cout << data[i][j];
		}
		cout << endl;
	}
}