#include<bits/stdc++.h>
#define READ freopen("in.txt","r",stdin);
#define WRITE freopen ("out.txt","w",stdout);
using namespace std;
int R[] = { -1, -1, -1, 0, 1, 1, 1, 0 };
int C[] = { -1, 0, 1, -1, -1, 0, 1, 1 };
int main()
{
// READ WRITE
int row, col,cas=0;
char ary[101][101];
while (~scanf("%d%d", &row, &col))
{
cas++;
if (row == 0 && col == 0) break;
if (cas != 1) printf("\n");
for (int i = 0; i < row; i++) cin >> ary[i];
printf("Field #%d:\n",cas);
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
if (ary[i][j] == '*') continue;
int count = 0;
for (int k = 0; k < 8; k++) if (ary[i + R[k]][j + C[k]] == '*') count++;
ary[i][j] = count+'0';
}
}
for (int i = 0; i < row; i++) cout << ary[i] << endl;
memset (ary,0,sizeof(ary));
}
return 0;
}
#define READ freopen("in.txt","r",stdin);
#define WRITE freopen ("out.txt","w",stdout);
using namespace std;
int R[] = { -1, -1, -1, 0, 1, 1, 1, 0 };
int C[] = { -1, 0, 1, -1, -1, 0, 1, 1 };
int main()
{
// READ WRITE
int row, col,cas=0;
char ary[101][101];
while (~scanf("%d%d", &row, &col))
{
cas++;
if (row == 0 && col == 0) break;
if (cas != 1) printf("\n");
for (int i = 0; i < row; i++) cin >> ary[i];
printf("Field #%d:\n",cas);
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
if (ary[i][j] == '*') continue;
int count = 0;
for (int k = 0; k < 8; k++) if (ary[i + R[k]][j + C[k]] == '*') count++;
ary[i][j] = count+'0';
}
}
for (int i = 0; i < row; i++) cout << ary[i] << endl;
memset (ary,0,sizeof(ary));
}
return 0;
}