import numpy as np

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

a = [list(input()) for i in range(h)]

a = np.array(a)

for hi in range(h):

    for wi in range(w):

        c = 0

        if a[hi][wi] == "#":

            print('#',end='')

        else:

            print(np.count_nonzero(a[max(0,hi-1):hi+2,max(0,wi-1):wi+2] == "#"),end='',)

    print()

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

f = [list(eval(input())) for _ in range(h)]

for k in range(h):

    for l in range(w):

        if f[k][l] == ".":

            c = 0

            for i in range(-1,2):

                for j in range(-1,2):

                    xi,yi = k+i,l+j

                    #xi,yiが範囲内で水溜りなら

                    if 0 <= xi < h  and 0 <= yi < w and f[xi][yi] == "#":

                        c += 1

            f[k][l] = str(c)



for m in range(h):

    print((''.join(f[m])))
import numpy as np

h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
a = np.array(a)
for hi in range(h):
    for wi in range(w):
        c = 0
        if a[hi][wi] == "#":
            print("#", end="")
        else:
            print(
                np.count_nonzero(
                    a[max(0, hi - 1) : hi + 2, max(0, wi - 1) : wi + 2] == "#"
                ),
                end="",
            )
    print()

h, w = list(map(int, input().split()))
f = [list(eval(input())) for _ in range(h)]
for k in range(h):
    for l in range(w):
        if f[k][l] == ".":
            c = 0
            for i in range(-1, 2):
                for j in range(-1, 2):
                    xi, yi = k + i, l + j
                    # xi,yiが範囲内で水溜りなら
                    if 0 <= xi < h and 0 <= yi < w and f[xi][yi] == "#":
                        c += 1
            f[k][l] = str(c)
for m in range(h):
    print(("".join(f[m])))

-import numpy as np - -h, w = map(int, input().split()) -a = [list(input()) for i in range(h)] -a = np.array(a) -for hi in range(h): -    for wi in range(w): -        c = 0 -        if a[hi][wi] == "#": -            print("#", end="") -        else: -            print( -                np.count_nonzero( -                    a[max(0, hi - 1) : hi + 2, max(0, wi - 1) : wi + 2] == "#" -                ), -                end="", -            ) -    print() +h, w = list(map(int, input().split())) +f = [list(eval(input())) for _ in range(h)] +for k in range(h): +    for l in range(w): +        if f[k][l] == ".": +            c = 0 +            for i in range(-1, 2): +                for j in range(-1, 2): +                    xi, yi = k + i, l + j +                    # xi,yiが範囲内で水溜りなら +                    if 0 <= xi < h and 0 <= yi < w and f[xi][yi] == "#": +                        c += 1 +            f[k][l] = str(c) +for m in range(h): +    print(("".join(f[m])))