#include<bits/stdc++.h>
#define x1 x__1
#define x2 x__2
#define y1 y__1
#define y2 y__2
using namespace std;
int n,m,x1,y1,x2,y2,k;
int a[1006][1006];
int sum[1006][1006];
int getint(){
	char c=getchar();short f=1;int now=0;
	if(c=='-'){f=-1;c=getchar();}
	while(c!='\n'&&c!=' '){
		now=now*10+c-'0';
		c=getchar();
	}
	return now*f;
}
int main(){
    n=getint();m=getint();k=getint();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			a[i][j]=getint();
			sum[i][j]=a[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
		}
	}
	while(k--){
		x1=getint();y1=getint();x2=getint();y2=getint();
		printf("%d\n",(sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1]));
	}
	return 0;
}

/**************************************************************
	Problem: 2061
	User: chenxurui
	Language: C++
	Result: Time Limit Exceed
****************************************************************/