//具体请看平板《算法基础二》笔记
import java.util.;
import java.io.;
public class Main{
public static void main(String args[]) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] strs1 = reader.readLine().split(” “);
int n = Integer.parseInt(strs1[0]); //n行
int m = Integer.parseInt(strs1[1]); //m列
int q = Integer.parseInt(strs1[2]); //询问个数
int[][] arr = new int[n][m]; //数列矩阵
int[][] s = new int[n+1][m+1]; //用来记录前矩阵和的辅助数列
for(int i = 0; i < n; i){
String[] strs2 = reader.readLine().split(” “);
for(int j = 0; j < m; j){
arr[i][j] = Integer.parseInt(strs2[j]); //给数列矩阵每个元素赋值
}
}
for(int i = 1; i <= n; i) //计算数列和
for(int j = 1; j <= m; j)
s[i][j] = s[i][j-1] + s[i-1][j] - s[i-1][j-1] + arr[i-1][j-1]; //注意s是从1开始,arr是从0开始
while(q– > 0){
String[] strs3 = reader.readLine().split(” “); //分别输入x1,y1,x2,y2
int x1 = Integer.parseInt(strs3[0]);
int y1 = Integer.parseInt(strs3[1]);
int x2 = Integer.parseInt(strs3[2]);
int y2 = Integer.parseInt(strs3[3]);
System.out.println(s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1]); //输出结果
}
}
}