#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=2050;
int pre[maxn][maxn],heng[maxn][maxn],shu[maxn][maxn];
bool map[maxn][maxn];
int n,m,q;
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(register int i=1;i<=n;i++){
		char s[maxn];
		scanf("%s",s);
		for(register int j=1;j<=m;j++){
			map[i][j]=s[j-1]-'0';
			pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+map[i][j];
			heng[i][j]=heng[i-1][j]+heng[i][j-1]-heng[i-1][j-1];
			shu[i][j]=shu[i-1][j]+shu[i][j-1]-shu[i-1][j-1];
			if(!map[i][j])continue;
			if(map[i][j]==map[i-1][j])heng[i][j]++;
			if(map[i][j]==map[i][j-1])shu[i][j]++;
		}
	}
	for(register int t=1,x1,y1,x2,y2;t<=q;t++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int toth=heng[x2][y2]-heng[x1][y2]-heng[x2][y1-1]+heng[x1][y1-1];
		int tots=shu[x2][y2]-shu[x1-1][y2]-shu[x2][y1]+shu[x1-1][y1];
		int tot=pre[x2][y2]-pre[x1-1][y2]-pre[x2][y1-1]+pre[x1-1][y1-1];
		printf("%d\n",tot-toth-tots);
	}
}