import java.util.Scanner; public class Main { private static void add(int[][] helper, int x1, int y1, int x2, int y2, int num) { helper[x1][y1] += num; helper[x1 + 1][y1 + 1] += num; helper[x1 + 1][y1] -= num; helper[x1][y1 + 1] -= num; } public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt(); int m = in.nextInt(); int q = in.nextInt(); int[][] arr = new int[n + 1][m + 1]; int[][] helper = new int[n + 2][m + 2]; for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m; ++ j) { arr[i][j] = in.nextInt(); add(helper, i, j, i, j, arr[i][j]); } } while (q -- > 0) { int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); int c = in.nextInt(); add(helper, x1, y1, x2, y2, c); } for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m; ++ j) { helper[i][j] += helper[i - 1][j] + helper[i][j - 1] - helper[i - 1][j - 1]; arr[i][j] = helper[i][j]; } } } } }