n, m, k = [int(i) for i in input().split()]
a = [[0] * m for i in range(n)]
for i in range(k):
row, col = (int(j) - 1 for j in input().split())
a[row][col] = -1
for i in range(n):
for j in range(m):
for di in range(-1, 2):
for dj in range(-1, 2):
if 0 <= i + di < n and 0 <= j + dj < m and a[i][j] != -1 and a[i + di][j + dj] == -1:
a[i][j] += 1
for i in range(n):
for j in range(m):
if a[i][j] == -1:
print("*", end=" ")
elif a[i][j] == 0:
print(".", end=" ")
else:
print(a[i][j], end=" ")
print()