import java.io.*;
public class Main{
int n,m,con=0;
int [][] matrizentera;
n=1;
m=1;
while (n!=0 && m!=0)
{
linea1=b.readLine();
V1=linea1.split(" ");
if (n!=0 && m!=0)
{
con++;
if (con>1)
{
}
matrizre
=new String [n
+2][m
+2];matrizentera=new int [n+2][m+2];
for(int s=0;s<n+2;s++)
{
for (int j=0;j<m+2;j++)
{
matriz[s][j]=".";
}
}
for(int s=0;s<n+2;s++)
{
for (int j=0;j<m+2;j++)
{
matrizentera[s][j]=0;
}
}
for(int x=1;x<n+2;x++)
{
linea=b.readLine();
V=linea.split("");
for (int y=1;y<m+2;y++)
{
matriz[x][y]=V[y-1];
if (y==m)
{
break;
}
} if (x==n)
{
break;
}
}
for (int x=1;x<n+1;x++)
{
for (int y=1;y<m+1;y++)
{
if(matriz[x][y].equals("*"))
{
matrizentera[x][y]=-1;
if ( !matriz[x][y+1].equals("*"))
{
matrizentera[x][y+1]++;
}
if ( !matriz[x][y-1].equals("*"))
{
matrizentera[x][y-1]++;
}
if ( !matriz[x-1][y].equals("*"))
{
matrizentera[x-1][y]++;
}
if ( !matriz[x+1][y].equals("*"))
{
matrizentera[x+1][y]++;
}
if ( !matriz[x-1][y+1].equals("*"))
{
matrizentera[x-1][y+1]++;
}
if ( !matriz[x-1][y-1].equals("*"))
{
matrizentera[x-1][y-1]++;
}
if ( !matriz[x+1][y+1].equals("*"))
{
matrizentera[x+1][y+1]++;
}
if ( !matriz[x+1][y-1].equals("*"))
{
matrizentera[x+1][y-1]++;
}
}
}
}
for(int s=0;s<n+2;s++)
{
for (int j=0;j<m+2;j++)
{
if (matrizentera[s][j]==-1)
{
matrizre[s][j]="*";
}else
{
matrizre
[s
][j
]= Integer.
toString(matrizentera
[s
][j
]);}
}
}
System.
out.
println("Field #"+con
+":");
for(int s=1;s<n+1;s++)
{
for (int j=1;j<m+1;j++)
{
System.
out.
print(matrizre
[s
][j
]);
}
}
}
}
}
aW1wb3J0IGphdmEuaW8uKjsKCnB1YmxpYyBjbGF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