include
include
using namespace std;
const int dx[8] = {1,-1,1,1,-1,-1,0,0},
dy[8] = {0,0,1,-1,1,-1,-1,1};//八个方向
int n,m;
char a[110][110];
bool isValid(int x,int y)
{
if (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == '')//判断当前搜索是否越界,且当前枚举点为“?”
return true;
return false;
}
int Search(int x,int y)//按照八个方向搜索
{
int ans = 0;
for (int i=0;i<8;++i)
{
int new_x= x + dx[i];
int new_y= y + dy[i];
if (isValid(new_x,new_y))
ans ++;//累加
}
return ans;//返回答案
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for (int j=1;j<=m;++j)
cin >> a[i][j];
//读入
for (int i=1;i<=n;++i)
for (int j=1;j<=m;++j)
{
if (a[i][j] == '')
cout << '*';
if (a[i][j] == '?')
cout << Search(i,j);//输出
if (j== m)
cout << endl;//换行
}
return 0;
}