H, W = map(int,input().split())
S = [input() for _ in range(H)]

for i in range(H):
  rs = ''
  for j in range(W):
    if(S[i][j] == '#'):
      rs += '#'
    else:
      tmp = 0
      for s in S[max(0, i-1): min(H, i+2)]:
        tmp += s[max(0, j-1): min(W, j+2)].count('#')
      rs += str(tmp)
  print(rs)