import java.util.Scanner;
public class Main
{
private static int N=1010;
private static int[][] a=new int[N][N];
private static int[][] s=new int[N][N];
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int m=scan.nextInt();
int q=scan.nextInt();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
a[i][j]=scan.nextInt();
//初始化前缀和
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]+a[i][j];
while(q--!=0)
{
int x1=scan.nextInt();
int y1=scan.nextInt();
int x2=scan.nextInt();
int y2=scan.nextInt();
int t=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
System.out.println(t);
}
scan.close();
}
}