#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 2005;
int N, M, Q;
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn];
char s[maxn];
int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for(int i=1; i<=N; ++i) {
		scanf("%s", s+1);
		for(int j=1; j<=M; ++j) 
			a[i][j] = s[j]-'0';
	}
	for(int i=1; i<N; ++i)
		for(int j=1; j<=M; ++j)
			if(a[i][j] && a[i+1][j]) ++b[i][j];
	for(int i=1; i<=N; ++i)
		for(int j=1; j<M; ++j)
			if(a[i][j] && a[i][j+1]) ++c[i][j];
	for(int i=1; i<=N; ++i)
		for(int j=1; j<=M; ++j) {
			a[i][j] += a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			b[i][j] += b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			c[i][j] += c[i-1][j]+c[i][j-1]-c[i-1][j-1];
		}
	int sx, sy, tx, ty, ans;
	while(Q--) {
		scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
		ans = a[tx][ty]-a[sx-1][ty]-a[tx][sy-1]+a[sx-1][sy-1];
		--tx;
		if(tx>=sx) ans-= b[tx][ty]-b[sx-1][ty]-b[tx][sy-1]+b[sx-1][sy-1];
		++tx; --ty;
		if(ty>=sy) ans-= c[tx][ty]-c[sx-1][ty]-c[tx][sy-1]+c[sx-1][sy-1];
		printf("%d\n", ans);
	}
	return 0;
}
