#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,k;
int a[1001][1001];
int b[1001][1001];
int x1,x2,y1,y2;
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		cin>>a[i][j];
		b[i][j]=b[i-1][j]+b[i][j-1]-b[i][j]+a[i][j];
	} 
	for(int i=1;i<=k;i++){
		cin>>x1>>y1>>x2>>y2;
		cout<<b[x2][y2]+b[x1-1][y1-1]-b[x2][y1-1]-b[x1-1][y2]<<endl;
	}
	return 0;
}
/**************************************************************
	Problem: 2061
	User: liuchengxuan
	Language: C++
	Result: Compile Error
****************************************************************/