import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
//普遍Scanner会超时,所以使用BufferedReader
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
String[] str1 = reader.readLine().split(" ");
int n = Integer.parseInt(str1[0]);
int m = Integer.parseInt(str1[1]);
int q = Integer.parseInt(str1[2]);
int[][] arr = new int[1010][1010];
for(int i=1;i<=n;i++){
String[] str2 = reader.readLine().split(" ");
for(int j=1;j<=m;j++){
arr[i][j] = Integer.parseInt(str2[j-1]);
insert(i,j,i,j,arr[i][j]);
}
}
while(q-- != 0){
String[] str3 = reader.readLine().split(" ");
int x1 = Integer.parseInt(str3[0]);
int y1 = Integer.parseInt(str3[1]);
int x2 = Integer.parseInt(str3[2]);
int y2 = Integer.parseInt(str3[3]);
int c = Integer.parseInt(str3[4]);
insert(x1,y1,x2,y2,c);
}
int[][] s = new int[1010][1010];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
s[i][j] = s[i-1][j] + s[i][j-1] -s[i-1][j-1] +b[i][j];
writer.write(s[i][j] + " ");
}
writer.write("\n");
}
//所有write下的内容,会先存在writers中,当启用flush以后,会输出存在其中的内容。如果没有调用flush,则不会将writer中的内容进行输出。
writer.flush();
reader.close();
writer.close();
}
static int[][] b =new int[1010][1010];
static void insert(int x1,int y1,int x2,int y2,int c){
b[x1][y1] = b[x1][y1]+c;
b[x2+1][y1] = b[x2+1][y1]-c;
b[x1][y2+1] = b[x1][y2+1]-c;
b[x2+1][y2+1] = b[x2+1][y2+1]+c;
}
}