//***只要你 目光是瞄准月亮 迷失过 又有何妨***//
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e3+10;
ll a[N][N];
int n,m,q;
int l1,l2,r1,r2;
int ans;
int sum;
ll pre[N][N];
void solve()
{
    cin>>n>>m>>q;
    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++)
        {
            pre[i][j]=a[i][j]+pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
        }
    }
    for (int i=1;i<=q;i++)
    {
        cin>>l1>>r1>>l2>>r2;
        cout<<pre[l2][r2]-pre[l2][r1-1]-pre[l1-1][r2]+pre[l1-1][r1-1]<<'\n';;
    }

}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}