#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[1001][1001],b[1001][1001],d[1001][1001],sx1,sx2,sy1,sy2,c; 
//a  1 2 3 4
//----------
//1  1 2 2 1
//2  3 2 2 1
//3  1 1 1 1
//
//b   1  2  3  4
//----------
//1|  2  1  1  -3
//2|  2 -2  0   0
//3|  -2 1  -1  2
//
//   2  3  4    1
//   4  ?
//
//?=4+3-2+-2
 
 
 
int main(){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
            b[i][j]=a[i][j]-(a[i][j-1]+a[i-1][j]-a[i-1][j-1]);
        }
    } 
    while(q--){
        scanf("%d%d%d%d%d",&sx1,&sy1,&sx2,&sy2,&c);
        b[sx1][sy1]+=c;
        b[sx1][sy2+1]-=c;
        b[sx2+1][sy1]-=c;
        b[sx2+1][sy2+1]+=c;
    }
 
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            //cout<<b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j]<<" ";
            d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1]+b[i][j];
            printf("%d ",d[i][j]); 
        }
        printf("\n"); 
    }
     
 
 
}
/**************************************************************
	Problem: 2351
	User: zhanghanbin
	Language: C++
	Result: Accepted
	Time:4 ms
	Memory:13820 kb
****************************************************************/