h,w=map(int,input().split())

l=[list(input()) for i in range(h)]
ans=[[0]*w for i in range(h)]

for i in range(h):
  for j in range(w):
    if l[i][j]=="#":
      ans[i][j]=="#"
    else:
      for a in range(-1,2):
        for b in range(-1,2):
          if i+a<h and j+b<w ansl[i+a][j+b]=="#":
            ans[i][j]+=1
            
for i in range(h):
  print(*ans[i])
