#include<stdio.h>
#define N 1000
int main()
{
int x, y, i, j, count, dig, m, n, s=1;
char a[N][N];
while(~scanf("%d%d", &x, &y)){
getchar();
if(x == 0&&y == 0) break;
printf("Field #%d:\n", s++);
for(i = 0; i < x; ++i)
//gets(a[i]);
scanf("%[^\n]\n", a[i]);
for(i = 0, count = 1; i < x; ++i){
for(j = 0; j < y; ++j, count++){
if(a[i][j] == '*')
printf("*");
else{
dig = 0;
for(m = i-1; m <= i+1; ++m)
for(n = j-1; n <= j+1; ++n){
if(m == i&&n == j) continue;
if(m >= 0&&m <= x&&n >= 0&&n <= y)
if(a[m][n]=='*')
dig++;
}
printf("%d", dig);
}
if(count%y == 0)
putchar(10);
}
}
putchar(10);
}
return 0;
}
0.0分
2 人评分