1 /*
2 * File: 10189.cpp
3 * Author: GongZhi
4 * Problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=29&page=show_problem&problem=1130
5 * Created on 2009年7月25日, 下午9:08
6 */
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <queue>
15 using namespace std;
16
17 /*
18 *
19 */
20 char ans[200][200];
21 int P[8][2] = {
22 {0, 1},
23 {0, -1},
24 {1, 0},
25 {-1, 0},
26 {1, -1},
27 {1, 1},
28 {-1, 1},
29 {-1, -1}
30 };
31
32 int main() {
33 int n, m, i, j, k, t,kase=1;
34 while (scanf("%d%d", &n, &m), n) {
35 for (i = 0; i < n; i++)scanf("%s", ans[i]);
36 for (i = 0; i < n; i++)
37 for (j = 0; j < m; j++) {
38 if (ans[i][j] == '*')continue;
39 t = 0;
40 for (k = 0; k < 8; k++)
41 if (i + P[k][0] >= 0 && i + P[k][0] < n && j + P[k][1] >= 0 && j + P[k][1] < m && ans[i + P[k][0]][j + P[k][1]] == '*')t++;
42 ans[i][j] = '0' + t;
43 }
44 if(kase!=1)printf("\n");
45 printf("Field #%d:\n",kase++);
46 for(i=0;i<n;i++)printf("%s\n",ans[i]);
47 }
48 return 0;
49 }