#include <iostream>
using namespace std;
int a[1005][1005];
long long pr[1005][1005];
int main() {
int n,m,k;
cin>>n>>m>>k;
long long pr[n+2][m+2]={};
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
cin>>a[i][j];
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
pr[i][j]=pr[i-1][j]+pr[i][j-1]-pr[i-1][j-1]+a[i][j];
for(int i=1; i<=k; i++){
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
long long s=pr[x2][y2]-pr[x2][y1-1]-pr[x1-1][y2]+pr[x1-1][y1-1];
cout<<s<<'\n';
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgYVsxMDA1XVsxMDA1XTsKbG9uZyBsb25nIHByWzEwMDVdWzEwMDVdOwppbnQgbWFpbigpIHsKCWludCBuLG0sazsKCWNpbj4+bj4+bT4+azsKCWxvbmcgbG9uZyBwcltuKzJdW20rMl09e307Cglmb3IoaW50IGk9MTsgaTw9bjsgaSsrKQoJCWZvcihpbnQgaj0xOyBqPD1tOyBqKyspCgkJCWNpbj4+YVtpXVtqXTsKCWZvcihpbnQgaT0xOyBpPD1uOyBpKyspCgkJZm9yKGludCBqPTE7IGo8PW07IGorKykKCQlwcltpXVtqXT1wcltpLTFdW2pdK3ByW2ldW2otMV0tcHJbaS0xXVtqLTFdK2FbaV1bal07Cglmb3IoaW50IGk9MTsgaTw9azsgaSsrKXsKCQlpbnQgeDEseTEseDIseTI7CgkJY2luPj54MT4+eTE+PngyPj55MjsKCQlsb25nIGxvbmcgcz1wclt4Ml1beTJdLXByW3gyXVt5MS0xXS1wclt4MS0xXVt5Ml0rcHJbeDEtMV1beTEtMV07Cgljb3V0PDxzPDwnXG4nOwoJfQp9Cg==