#include<bits/stdc++.h> #define x1 x_1 #define x2 x_2 #define y1 y_1 #define y2 y_2 using namespace std; int n,m,x1,y1,x2,y2,k; int a[1006][1006]; long long sum[1006][1006]; 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]; sum[i][j]=a[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]; } } while(k--){ cin>>x1>>y1>>x2>>y2; cout<<(sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1])<<endl; } return 0; } /************************************************************** Problem: 2061 User: chenxurui Language: C++ Result: Time Limit Exceed ****************************************************************/