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

using namespace std;



#define FOR(i,a,b) for(int i = (a); i < (b); i++)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)

#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int) a.size()

#define ALL(a) a.begin(),a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const LL INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 2020;



int V[MAX][MAX];

int EX[MAX][MAX];

int EY[MAX][MAX];

char S[MAX][MAX];



int getS(int x1, int y1, int x2, int y2, int a[][MAX])

{

	int res = a[x2][y2];

	if (x1) res -= a[x1-1][y2];

	if (y1) res -= a[x2][y1 - 1];

	if (x1 && y1) res += a[x1-1][y1-1];

	return res;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//ios::sync_with_stdio(false); cin.tie(0);



	int n, m, q;

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

	FOR (i, 0, n)

	{

		scanf("%s", S[i]);

		FOR (j, 0, m)

		{

			S[i][j] -= '0';

		}

	}



	FOR (i, 0, n)

	{

		FOR (j, 0, m)

		{

			V[i][j] += S[i][j];

			if (i) V[i][j] += V[i-1][j];

			if (j) V[i][j] += V[i][j-1];

			if (i && j) V[i][j] -= V[i-1][j-1];



			if (i) EX[i][j] += S[i][j] & S[i-1][j];

			if (j) EY[i][j] += S[i][j] & S[i][j-1];



			if (i) EX[i][j] += EX[i-1][j];

			if (j) EX[i][j] += EX[i][j-1];

			if (i && j) EX[i][j] -= EX[i-1][j-1];



			if (i) EY[i][j] += EY[i-1][j];

			if (j) EY[i][j] += EY[i][j-1];

			if (i && j) EY[i][j] -= EY[i-1][j-1];

		}

	}



	FOR (i, 0, q)

	{

		int x1, y1, x2, y2;

		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

		x1--;

		y1--;

		x2--;

		y2--;



		int v = getS(x1, y1, x2, y2, V);

		int ex = getS(x1 + 1, y1, x2, y2, EX);

		int ey = getS(x1, y1 + 1, x2, y2, EY);



		int e = ex + ey;



		int cnt = v - e;

		printf("%d\n", cnt);



	}



}


// Faster C++ solution for the same problem (measured speedup: 4.970711931424489x):
#include <stdio.h>

#define MN 2005

int n,m,q,pnt[MN][MN],row[MN][MN],col[MN][MN];

bool b[MN][MN];

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",&b[i][j]);

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

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

			pnt[i][j]=pnt[i-1][j]+pnt[i][j-1]-pnt[i-1][j-1]; if(b[i][j])pnt[i][j]++;

//			printf("%d ",pnt[i][j]);

		}

//		printf("\n");

	}

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

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

			row[i][j]=row[i-1][j]+row[i][j-1]-row[i-1][j-1]; if(b[i][j]&&b[i+1][j])row[i][j]++;

//			printf("%d ",row[i][j]);

		}

//		printf("\n");

	}

//	printf("\n");

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

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

			col[i][j]=col[i-1][j]+col[i][j-1]-col[i-1][j-1]; if(b[i][j]&&b[i][j+1])col[i][j]++;

//			printf("%d ",col[i][j]);

		}

//		printf("\n");

	}

//	printf("\n");

	for(int i=1;i<=q;i++){

		int xa,xb,ya,yb;

		scanf("%d%d%d%d",&xa,&ya,&xb,&yb);

//		printf("%d ",(pnt[xb][yb]-pnt[xa-1][yb]-pnt[xb][ya-1]+pnt[xa-1][ya-1]));

//		printf("%d ",(row[xb-1][yb]-row[xa-1][yb]-row[xb-1][ya-1]+row[xa-1][ya-1]));

//		printf("%d ",(col[xb][yb-1]-col[xa-1][yb-1]-col[xb][ya-1]+col[xa-1][ya-1]));

		printf("%d\n",

			 (pnt[xb][yb]-pnt[xa-1][yb]-pnt[xb][ya-1]+pnt[xa-1][ya-1])

			-(row[xb-1][yb]-row[xa-1][yb]-row[xb-1][ya-1]+row[xa-1][ya-1])

			-(col[xb][yb-1]-col[xa-1][yb-1]-col[xb][ya-1]+col[xa-1][ya-1])

		);

	}

}