import java.util.*;

public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int q = sc.nextInt(); //存放数组元素 int[][] arr=new int[n][m]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ arr[i][j]=sc.nextInt(); } } //存放增量 long[][] delta=new long[n+2][m+2]; //q次操作 while(q-->0){ int x1=sc.nextInt(); int y1=sc.nextInt(); int x2=sc.nextInt(); int y2=sc.nextInt(); int k=sc.nextInt(); //进行差分处理 delta[x1][y1]+=k; delta[x1][y2+1]-=k; delta[x2+1][y1]-=k; delta[x2+1][y2+1]+=k; }

    //计算前缀和还原对应元素的增量
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            delta[i+1][j+1]+=delta[i][j+1];
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            delta[i+1][j+1]+=delta[i+1][j];
            System.out.print(delta[i+1][j+1]+arr[i][j]+" ");
        }
        System.out.println();
    }
        
    
}

}