h,w=map(int,input().split())
s,t=[list(input()) for i in range(h)],[[0 for j in range(w+2)] for i in range(h+2)]
for i in range(h):
	for j in range(w):
		if s[i][j]=='.':
			continue
		for p in range(9):
			t[i+p//3][j+p%3]+=1
for i in range(h):
	for j in range(w):
		if s[i][j]=='.':
			s[i][j]=str(t[i+1][j+1])
	print("".join(s[i]))
