h,w=map(int,input().split())
s=[]
for _ in range(h):
  s.append(input())
ans=[[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      ans[i][j]='#'
      continue
    i0=max(0,i-1)
    i1=min(i+1,h-1)
    j0=max(0,j-1)
    j1=min(j+1,w-1)
    p=0
    for _ in range(i0,i1+1):
      p += s[_][j0:j1+1].count('#')
    ans[i][j]=p
#print(s)
for ansi in ans:
  print(''.join(map(str,ansi)))
