import java.util.Scanner;

/**
 * @author supermejane
 * @date 2025/10/6
 * @description 【模板】二维前缀和
 */
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int height = in.nextInt(), width = in.nextInt(), n = in.nextInt();
	  	//数组为long[height + 1][width + 1]便于处理边界
        long[][] a = new long[height + 1][width + 1], sum = new long[height + 1][width + 1];
        for (int i = 1; i <= height; i++) {
            for (int j = 1; j <= width; j++) {
                a[i][j] = in.nextInt();
                sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
            }
        }
        while (n-- > 0) {
            int x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.nextInt(), y2 = in.nextInt();
            System.out.println(sum[x2][y2] - sum[x1 -1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1]);
        }
    }
}