#include<stdio.h> int main() { int i, j,m,n; int a[500][500]; scanf("%d%d", &m, &n);//输入m x n数组 for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) scanf("%d", &a[i][j]); int q; scanf("%d", &q); while (q--) { int x1, x2, x3, x4; int sum = 0; scanf("%d%d%d%d", &x1, &x2, &x3, &x4); for(i=x1;i<=x2;i++) for (j = x3; j <= x4; j++) { sum = sum + a[i][j]; } printf("%d\n", sum); } return 0; }