#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, M, Q;
int A[MAXN][MAXN];
int f[MAXN][MAXN], g[MAXN][MAXN], h[MAXN][MAXN];

int main() {
	register int i, j; int x1, y1, x2, y2;
	scanf("%d%d%d", &N, &M, &Q);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			scanf("%01d", A[i] + j);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + A[i][j],
			g[i][j] = g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + (A[i][j] == 1 && A[i][j - 1] == 1),
			h[i][j] = h[i - 1][j] + h[i][j - 1] - h[i - 1][j - 1] + (A[i][j] == 1 && A[i - 1][j] == 1);
	while(Q--) {
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int x = f[x2][y2] - f[x1 - 1][y2] - f[x2][y1 - 1] + f[x1 - 1][y1 - 1];
		int y = g[x2][y2] - g[x1 - 1][y2] - g[x2][y1] + g[x1 - 1][y1];
		int z = h[x2][y2] - h[x1][y2] - h[x2][y1 - 1] + h[x1][y1 - 1];
		printf("%d\n", x - y - z);
	}
	return 0;
}