#include <iostream>
#include <cstdio>
#define N 2005
using namespace std;

int n, m, q, x1, y1, x2, y2, a[N][N], b[N][N], c[N][N];
char t[N][N];
int main()
{
	int i, j, t1;
	cin >> n >> m >> q;
	for (i = 1; i <= n; i++) {
		scanf("%s", &t[i][1]);
		for (j = 1; j <= m; j++) {
			a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + t[i][j] - '0';
			b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1] + (t[i][j] - '0' & t[i][j - 1] - '0');
			c[i][j] = c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1] + (t[i][j] - '0' & t[i - 1][j] - '0');
		}
	}
	while (q--) {
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		t1 = a[x2][y2] - a[x2][y1 - 1] - a[x1 - 1][y2] + a[x1 - 1][y1 - 1];
		t1 -= b[x2][y2] - b[x2][y1] - b[x1 - 1][y2] + b[x1 - 1][y1];
		t1 -= c[x2][y2] - c[x2][y1 - 1] - c[x1][y2] + c[x1][y1 - 1];
		printf("%d\n", t1);
	}
    return 0;
}