n,m,q = map(int,input().split())
A,inquire = [],[]
def insert(b,x1,y1,x2,y2,c):
b[x1][y1]+=c
b[x1][y2+1]-=c
b[x2+1][y1]-=c
b[x2+1][y2+1]+=c
for i in range(n):
A.append(list(map(int,input().split())))
B = [[0]*(m+10) for i in range(n+10)]
for i in range(1,n+1):
for j in range(1,m+1):
insert(B,i,j,i,j,A[i-1][j-1])
while q>0:
q -=1
x1,y1,x2,y2,c = (map(int,input().split()))
insert(B,x1,y1,x2,y2,c)
for i in range(1,n+1):
for j in range(1,m+1):
B[i][j] = B[i-1][j]+B[i][j-1] -B[i-1][j-1]+B[i][j]
for i in range(1,n+1):
for j in range(1,m+1):
print(B[i][j],end=' ')
print()