#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);
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];
}
}
while(k--){
int x_1,y_1,x_2,y_2;
cin>>x_1>>y_1>>x_2>>y_2;
cout<<b[x_2][y_2]-b[x_2][y_1-1]-b[x_1-1][y_2]+b[x_1-1][y_1-1]<<endl;
}
return 0;
}
/**************************************************************
Problem: 2061
User: caizhihao
Language: C++
Result: Time Limit Exceed
****************************************************************/