H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = []
for i, g in enumerate(grid):
    r = ''
    for j, s in enumerate(g):
        if s == '#':
            r += s
        else:
            r += str(sum([temp[max(j-1, 0): min(j+1, W)+1].count('#') for temp in grid[max(i-1, 0): min(i+1, H)+1]]))
    ans.append(r)
print(*ans, sep='\n')