// Slower C++ solution:
#include <bits/stdc++.h>

#define x first

#define y second

#define y1 secondy1

#define rank tipa_rank

#define pb push_back

#define mp make_pair

#define pow10 tipa_pow10

#define ll long long

#define INF 1000000000

#define EPS 1e-9

#define EPS2 1e-8

#define PI acos(-1.0)

using namespace std;

const int MOD = INF + 7;

const int base = 2;

int prefSum[2000][2000];

int prefSum2[2000][2000];

int prefSum3[2000][2000];

int a[2000][2000];

int b[2000][2000];

int c[2000][2000];

int sum(int x1 , int y1 , int x2 , int y2)

{

	int ans = prefSum[x2][y2];

	if(x1 && y1)

		ans += prefSum[x1 - 1][y1 - 1];

	if(x1)

		ans -= prefSum[x1 - 1][y2];

	if(y1)

		ans -= prefSum[x2][y1 - 1];

	return ans;

}

int sum2(int x1 , int y1 , int x2 , int y2)

{

	int ans = prefSum2[x2][y2];

	if(x1 && y1)

		ans += prefSum2[x1 - 1][y1 - 1];

	if(x1)

		ans -= prefSum2[x1 - 1][y2];

	if(y1)

		ans -= prefSum2[x2][y1 - 1];

	return ans;

}

int sum3(int x1 , int y1 , int x2 , int y2)

{

	int ans = prefSum3[x2][y2];

	if(x1 && y1)

		ans += prefSum3[x1 - 1][y1 - 1];

	if(x1)

		ans -= prefSum3[x1 - 1][y2];

	if(y1)

		ans -= prefSum3[x2][y1 - 1];

	return ans;

}

int q , n , m;

int main()

{

	scanf("%d %d %d" , &n , &m , &q);

	for(int i = 0; i < n; i++)

	{

		for(int j = 0; j < m; j++)

		{

			scanf("%1d" , &a[i][j]);

			if(i && a[i][j] && a[i - 1][j])

				b[i][j]++;

			if(j && a[i][j] && a[i][j - 1])

				c[i][j]++;

		}

	}

	for(int i = 0; i < n; i++)

	{

		for(int j = 0; j < m; j++)

		{

			if(!j)

			{

				prefSum[i][j] = a[i][j];

			}

			else

			{

				prefSum[i][j] = prefSum[i][j - 1] + a[i][j];

			}

		}

	}

	for(int i = 0; i < m; i++)

	{

		for(int j = 0; j < n; j++)

		{

			if(j)

			{

				prefSum[j][i] = prefSum[j][i] + prefSum[j - 1][i];

			}

		}

	}

	for(int i = 0; i < n; i++)

	{

		for(int j = 0; j < m; j++)

		{

			if(!j)

			{

				prefSum2[i][j] = b[i][j];

			}

			else

			{

				prefSum2[i][j] = prefSum2[i][j - 1] + b[i][j];

			}

		}

	}

	for(int i = 0; i < m; i++)

	{

		for(int j = 0; j < n; j++)

		{

			if(j)

			{

				prefSum2[j][i] = prefSum2[j][i] + prefSum2[j - 1][i];

			}

		}

	}

	for(int i = 0; i < n; i++)

	{

		for(int j = 0; j < m; j++)

		{

			if(!j)

			{

				prefSum3[i][j] = c[i][j];

			}

			else

			{

				prefSum3[i][j] = prefSum3[i][j - 1] + c[i][j];

			}

		}

	}

	for(int i = 0; i < m; i++)

	{

		for(int j = 0; j < n; j++)

		{

			if(j)

			{

				prefSum3[j][i] = prefSum3[j][i] + prefSum3[j - 1][i];

			}

		}

	}



	for(int i = 0; i < q; i++)

	{

		int X1 , Y1 , X2 , Y2;

		scanf("%d %d %d %d" , &X1 , &Y1 , &X2 , &Y2);

		X1--;Y1--;X2--;Y2--;

		int ans = sum(X1 , Y1 , X2 , Y2);

		//cout << ans << endl;

		int ans2 = sum2(X1 + 1 , Y1 , X2 , Y2);

		int ans3 = sum3(X1 , Y1 + 1 , X2 , Y2);

		printf("%d\n" , ans - ans2 - ans3);

	}

}


// Faster C++ solution for the same problem (measured speedup: 4.977007939321693x):
#include<cstdio>

using namespace std;

int x,y,xx,yy,n,m,q,c[2005][2005],cnt[2005][2005],e[2005][2005],e2[2005][2005],e3[2005][2005];

int main(){

	scanf("%d%d%d",&n,&m,&q);

	for(int i=1;i<=n;++i)

		for(int j=1;j<=m;++j){

			scanf("%1d",&c[i][j]);

			e2[i][j]=e2[i][j-1];e3[i][j]=e3[i-1][j];

			if(c[i][j]&&c[i][j-1]) ++e2[i][j];

			if(c[i][j]&&c[i-1][j]) ++e3[i][j];

		}

	for(int i=1;i<=n;++i)

		for(int j=1;j<=m;++j){

			cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+c[i][j];

			e[i][j]=e[i-1][j]+e[i][j-1]-e[i-1][j-1];

			if(c[i][j]){

				if(c[i-1][j]) ++e[i][j];

				if(c[i][j-1]) ++e[i][j];

			}

		}

	while(q--){

		scanf("%d%d%d%d",&x,&y,&xx,&yy);--x;--y;

//		printf("**%d %d**\n",cnt[xx][yy]+cnt[x][y]-cnt[x][yy]-cnt[xx][y],e[xx][yy]+e[x+1][y+1]-e[x+1][yy]-e[xx][y+1]+e2[x+1][yy]-e2[x+1][y+1]+e3[xx][y+1]-e3[x+1][y+1]);

		printf("%d\n",cnt[xx][yy]+cnt[x][y]-cnt[x][yy]-cnt[xx][y]-(e[xx][yy]+e[x+1][y+1]-e[x+1][yy]-e[xx][y+1]+e2[x+1][yy]-e2[x+1][y+1]+e3[xx][y+1]-e3[x+1][y+1]));

	}

}