h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    ans=""
    for j in range(w):
        if(s[i][j] =="#"):
            ans+="#"
        else:
            c=0
            for ss in s[max(0,i-1):min(h,i+2)]:
                c+=ss[max(0,j-1):min(w,j+2)].count("#")
            ans+= str(c)
    print(ans)