#include <cstdio>
#define N 2005][2005
int n, m, Q, s, b[N], c[N], d[N];
char a[N];
int main() {
	int i, j, p, q, x, y;
	scanf("%d%d%d", &n, &m ,&Q);
	for(i=1; i<=n; i++) scanf("%s", &a[i][1]);
	for(i=1; i<=n; i++) for(j=1; j<=m; j++) b[i][j] = b[i-1][j] + b[i][j-1] - b[i-1][j-1] + (a[i][j]=='1');
	for(i=1; i<=n; i++) for(j=1; j<m; j++)  c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j]=='1' && a[i][j+1]=='1');
	for(i=1; i<n; i++)  for(j=1; j<=m; j++) d[i][j] = d[i-1][j] + d[i][j-1] - d[i-1][j-1] + (a[i][j]=='1' && a[i+1][j]=='1');
	while(Q--) {
		scanf("%d%d%d%d", &p, &q ,&x, &y);
		p--, q--, s = b[x][y] - b[x][q] - b[p][y] + b[p][q];
			 y--, s-= c[x][y] - c[x][q] - c[p][y] + c[p][q];
		x--, y++, s-= d[x][y] - d[x][q] - d[p][y] + d[p][q];
		printf("%d\n", s);
	}
	return 0;
}