#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[1002][1002];
int b[1002][1002]={0},n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]=="*"){
b[i][j]++;
b[i-1][j-1]++;
b[i-1][j]++;
b[i-1][j+1]++;
b[i][j-1]++;
b[i][j+1]++;
b[i+1][j-1]++;
b[i+1][j]++;
b[i+1][j+1]++;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]=="*") cout<<"*";
else cout<<b[i][j];
}
cout<<endl;
}
return 0;