#include <bits/stdc++.h>
using namespace std;
int u[100]={-1,0,1,-1,0,1,-1,0,1};
int y[100]={-1,-1,-1,0,0,0,1,1,1};
char sbh[101][101];
int main()
{
int a,b;
cin>>a>>b;
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
cin>>sbh[i][j];
}
}
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
if(sbh[i][j]=='*')
{
for(int p=0;p<8;p++)
{
if(sbh[i+u[p]][j+y[p]]!='*')
sbh[i+u[p]][j+y[p]]+=1;
}
}
}
}
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
if(sbh[i][j]=='*')
{
cout<<sbh[i][j];
}
else
{
cout<<sbh[i][j]-'?';
}
}
cout<<endl;
}
}