m, n, q = map(int, input().split())
b = [[0] * (n + 2) for _ in range(m + 2)]
# 差分矩阵左上角为i1, j1 右下角为i2, j2的子矩阵增加数值c
def insert(i1, j1, i2, j2, c):
b[i1][j1] += c
b[i1][j2 + 1] -= c
b[i2 + 1][j1] -= c
b[i2 + 1][j2 + 1] += c
for i in range(1, m + 1):
arr = list(map(int, input().split()))
for j in range(1, n + 1):
insert(i, j, i, j, arr[j - 1])
for _ in range(q):
i1, j1, i2, j2, c = map(int, input().split())
insert(i1, j1, i2, j2, c)
# 前缀和还原数组
for i in range(1, m + 1):
for j in range(1, n + 1):
b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1]
print(' '.join(map(str, b[i][1:-1])))