import sys
def insert(x1, y1, x2, y2, c):
b[x1][y1] += c
if x2 + 1 < n:
b[x2+1][y1] -= c
if y2 + 1 < m:
b[x1][y2+1] -= c
if x2+1 < n and y2+1 < m:
b[x2+1][y2+1] += c
lines = sys.stdin.readlines()
n, m, q = list(map(int, lines[0].strip().split()))
matrix = []
for i in range(1, n+1):
matrix.append(list(map(int, lines[i].strip().split())))
b = [[0] * m for _ in range(n)]
for i in range(n):
for j in range(m):
insert(i, j, i, j, matrix[i][j])
for i in range(n+1, len(lines)):
x1, y1, x2, y2, c = list(map(int, lines[i].strip().split()))
insert(x1-1, y1-1, x2-1, y2-1, c)
s = [[0] * (m+1) for _ in range(n+1)]
for i in range(1,n+1):
for j in range(1,m+1):
s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + b[i-1][j-1]
for i in range(1, n+1):
print(*s[i][1:])