#include<cstdio>
#include<cstring>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define ask(a) (a[x2][y2]+a[x1][y1]-a[x1][y2]-a[x2][y1])
using namespace std;
const int N=2010;
int get(){
	char ch;
	while ((ch=getchar())!='0'&&ch!='1');
	return ch-'0';
}
int n,m,q,x1,x2,y1,y2,ans,mp[N][N],s1[N][N],s2[N][N],s3[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	rep(i,1,n) rep(j,1,m) mp[i][j]=get();
	rep(i,1,n) rep(j,1,m){
		s1[i][j]=mp[i][j];
		s2[i][j]=mp[i][j]&mp[i+1][j];
		s3[i][j]=mp[i][j]&mp[i][j+1];
	}
	rep(i,1,n) rep(j,1,m)
		s1[i][j]+=s1[i][j-1],
		s2[i][j]+=s2[i][j-1],
		s3[i][j]+=s3[i][j-1];
	rep(i,1,n) rep(j,1,m)
		s1[i][j]+=s1[i-1][j],
		s2[i][j]+=s2[i-1][j],
		s3[i][j]+=s3[i-1][j];
	rep(i,1,q){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		--x1,--y1;
		ans=ask(s1);
		--x2,ans-=ask(s2),++x2;
		--y2,ans-=ask(s3);
		printf("%d\n",ans);
	}
	return 0;
}