n, m, q = map(int,input().split())
# 差分矩阵, 大小设为 (n+2)x(m+2)
d = [[0]*(m+2) for _ in range(n+2)]
a = [[0]*(m+1) for _ in range(n+1)]
# 1. 构建初始差分矩阵
for i in range(1,n+1):
row = list(map(int,input().split()))
for j in range(1,m+1):
a[i][j] = row[j-1]
d[i][j] = a[i][j]-a[i][j-1]-a[i-1][j]+a[i-1][j-1]
# 2. 处理所有修改
for _ in range(q):
x1, y1, x2, y2, c = map(int,input().split())
d[x1][y1] += c
d[x1][y2+1] -= c
d[x2+1][y1] -= c
d[x2+1][y2+1] += c
# 3. 通过前缀和还原最终矩阵
final_a = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
row_a = []
for j in range(1,m+1):
final_a[i][j] = d[i][j]+final_a[i][j-1]+final_a[i-1][j]-final_a[i-1][j-1]
row_a.append(final_a[i][j])
print(*row_a)