#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=2100;
char a[N][N];
int n,m,Q;
int f[N][N],gy[N][N],gx[N][N];
int Query(int sum[N][N],int x1,int x2,int y1,int y2){
	if(x1>x2)return 0;
	if(y1>y2)return 0;
	//printf("_%d\n",sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]);
	return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	rep(i,1,n)scanf("%s",a[i]+1);
	rep(i,1,n)rep(j,1,m){
		f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(a[i][j]=='1');
		gx[i][j]=gx[i-1][j]+gx[i][j-1]-gx[i-1][j-1];
		gy[i][j]=gy[i-1][j]+gy[i][j-1]-gy[i-1][j-1];
		if(i+1<=n&&a[i][j]=='1'&&a[i+1][j]=='1')gx[i][j]++;
		if(j+1<=m&&a[i][j]=='1'&&a[i][j+1]=='1')gy[i][j]++;
	}
	while(Q--){
		int x1,x2,y1,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",Query(f,x1,x2,y1,y2)-Query(gx,x1,x2-1,y1,y2)-Query(gy,x1,x2,y1,y2-1));
	}
	return 0;
}

