#include<bits/stdc++.h>
using namespace std;
int n, m, k;
int a[1005][1005], b[1005][1005];
int main() {
// 关闭输入输出流同步,禁用cin与stdin的同步
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// 读取输入数据
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] - b[i-1][j-1] + a[i][j];
}
}
// 处理查询
for(int q = 0; q < k; q++) {
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
****************************************************************/