Minesweeper
c=1
while 1:
try:
a,b=map(int,input().split())
if a==b==0:
break
if c>1:
print()
print('Field #'+str(c)+':')
c+=1
arr=[]
for i in range(a):
arr.append(list(input()))
for i in range(a):
for j in range(b):
if arr[i][j]=='*':
print(arr[i][j],end="")
continue
else:
arr[i][j]=0
if j-1>=0:
if arr[i][j-1]=='*':
arr[i][j]+=1
if j+1<b:
if arr[i][j+1]=='*':
arr[i][j]+=1
if i-1>=0:
if arr[i-1][j]=='*':
arr[i][j]+=1
if i+1<a:
if arr[i+1][j]=='*':
arr[i][j]+=1
if i-1>=0 and j-1>=0:
if arr[i-1][j-1]=='*':
arr[i][j]+=1
if i+1<a and j+1<b:
if arr[i+1][j+1]=='*':
arr[i][j]+=1
if i-1>=0 and j+1<b:
if arr[i-1][j+1]=='*':
arr[i][j]+=1
if i+1<a and j-1>=0:
if arr[i+1][j-1]=='*':
arr[i][j]+=1
print(arr[i][j],end="")
print()
except:
break