import numpy as np

H,W= list(map(int,input().split()))
a=np.array([list(input()) for i in range(H)])
b=np.zeros((H,W))
print(a[0][0])
print(b)

for i in range(H):
    for j in range(W):
        if a[i][j]=="#":
            if i>=1 and j>=1:
                b[i-1][j-1] += 1
            if i>=1:
                b[i-1][j] += 1
            if i>=1 and j<W-1:
                b[i-1][j+1] +=1

            if j>=1:
                b[i][j-1] += 1
            #    b[i][j] += 1
            if j<W-1:
                b[i][j+1] +=1

            if i<H-1 and j>=1:
                b[i+1][j-1] += 1
            if i<H-1:
                b[i+1][j] += 1
            if i<H-1 and j<W-1:
                b[i+1][j+1] +=1

print(b)
