#include<bits/stdc++.h>
using namespace std;
#define MN 2005
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,q;
bool mp[MN][MN];
int l[MN][MN],h[MN][MN],b[MN][MN];
int main(){
	n=read(),m=read(),q=read();char c[MN];
	for(int i=1;i<=n;i++){
		scanf("%s",c+1);
		for(int j=1;j<=m;j++) mp[i][j]=c[j]=='1';
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
		l[i][j]=l[i-1][j]+l[i][j-1]-l[i-1][j-1]+(mp[i][j]&&mp[i][j-1]);
		h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+(mp[i][j]&&mp[i-1][j]);
		b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(mp[i][j]);
	}
	int ans,x1,y1,x2,y2;
	while(q--){
		x1=read(),y1=read(),x2=read(),y2=read();
		ans=0;
		ans+=b[x2][y2]-b[x2][y1-1]-b[x1-1][y2]+b[x1-1][y1-1];
		ans-=l[x2][y2]-l[x2][y1]-l[x1-1][y2]+l[x1-1][y1];
		ans-=h[x2][y2]-h[x2][y1-1]-h[x1][y2]+h[x1][y1-1];
		printf("%d\n",ans);
	}
	return 0;
}