#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 2100
using namespace std;
int n,m,q,a[N][N],s[N][N],s1[N][N],s2[N][N],cnt,h[N][N];
char st[N];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",st+1);
		for(int j=1;j<=m;j++) 
		{
			a[i][j]=st[j]-'0';
			s[i][j]=a[i][j]+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
			h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1];
			if(a[i][j] && a[i-1][j]) h[i][j]++;
			if(a[i][j] && a[i][j-1]) h[i][j]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) if(a[i][j] && a[i-1][j]) s1[i][j]=1,cnt++;
		for(int j=1;j<=m;j++) s1[i][j]+=s1[i][j-1];
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++) if(a[j][i] && a[j][i-1]) s2[i][j]=1,cnt++;
		for(int j=1;j<=n;j++) s2[i][j]+=s2[i][j-1];
	}
	while(q--)
	{
		int x1,y1,x2,y2,v,e;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		v=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
		e=h[x2][y2]-h[x1-1][y2]-h[x2][y1-1]+h[x1-1][y1-1];
		e-=s1[x1][y2]-s1[x1][y1-1]+s2[y1][x2]-s2[y1][x1-1];
		printf("%d\n",v-e);
	}
	return 0;
}