#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int a[1005][1005],b[1005][1005];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
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]+a[i][j]-b[i-1][j-1];
}
}
for(int i=1;i<=k;i++){
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
cout<<b[x2][y2]-b[x2][y1-1]-b[x1-1][y2]+b[x1-1][y1-1]<<endl;
}
return 0;
}
/**************************************************************
Problem: 2061
User: caizhihao
Language: C++
Result: Compile Error
****************************************************************/