def insert(diff, x1, y1, x2, y2, c):
    diff[x1][y1] += c
    diff[x2 + 1][y1] -= c
    diff[x1][y2 + 1] -= c
    diff[x2 + 1][y2 + 1] += c


n, m, q = map(int, input().split())
diff = [[0] * (m + 2) for _ in range(n + 2)]
# 初始化差分矩阵
for i in range(1, n + 1):
    row = list(map(int, input().split()))
    for j in range(1, m + 1):
        insert(diff, i, j, i, j, row[j - 1])
# 处理 q 次操作
for _ in range(q):
    x1, y1, x2, y2, c = map(int, input().split())
    insert(diff, x1, y1, x2, y2, c)
# 还原最终矩阵(二维前缀和)
for i in range(1, n + 1):
    for j in range(1, m + 1):
        diff[i][j] += diff[i - 1][j] + diff[i][j - 1] - diff[i - 1][j - 1]
        print(diff[i][j], end=" " if j < m else "\n")