H, W, N = map(int, input().split())
ab = [[0]*W for _ in range(H)]
for i in range(N):
r, c, t, x = map(int, input().split())
for a in range(H):
for b in range(W):
if (abs(r-a) + abs(b-c)) <= t:
ab[a][b] += x
for row in ab:
print(' '.join(map(str, row)))
H, W, N = map(int, input().split())
ab = [[0]*W for _ in range(H)]
for i in range(N):
r, c, t, x = map(int, input().split())
for a in range(H):
for b in range(W):
if (abs(r-a) + abs(b-c)) <= t:
ab[a][b] += x
for row in ab:
print(' '.join(map(str, row)))
for row in ab:
print(*row)