#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,q;
char ma[2010][2010];
int a[2010][2010],li[2010][2010],ha[2010][2010];
int main(){
	int i,j;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;++i){
		scanf("%s",ma[i]);
		for(j=m;j>=1;--j)  ma[i][j]=ma[i][j-1];
	}
	memset(a,0,sizeof(a));
	memset(li,0,sizeof(li));
	memset(ha,0,sizeof(ha));
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			li[i][j]=li[i-1][j]+li[i][j-1]-li[i-1][j-1];
			ha[j][i]=ha[j][i-1]+ha[j-1][i]-ha[j-1][i-1];
			if(ma[i][j]=='1'){
				a[i][j]++;
			}
			if(ma[i][j]=='1' && ma[i][j-1]=='1'){
				li[i][j]++;
			}
			if(ma[i][j]=='1' && ma[i-1][j]=='1'){
				ha[j][i]++;
			}
		}
	}
	int x,y,xa,ya;
	for(i=1;i<=q;++i){
		scanf("%d%d%d%d",&x,&y,&xa,&ya);
		int one=a[xa][ya]-a[x-1][ya]-a[xa][y-1]+a[x-1][y-1];
		int ans,kk;
		kk=li[xa][ya]-li[xa][y]-li[x-1][ya]+li[x-1][y];
		kk+=ha[ya][xa]-ha[ya][x]-ha[y-1][xa]+ha[y-1][x];
		ans=one-kk;
		printf("%d\n",ans);
	}
	return 0;
}