// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

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 int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 2 * 1000 + 47;

const int MOD = 1000 * 1000 * 1000 + 7;



string A[MAX];

int P1[MAX][MAX];

int P2[MAX][MAX];

int P3[MAX][MAX];



void recalc(int i, int j, int P1[MAX][MAX])

{

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

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

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

}



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

{

	int res = P1[x2][y2];

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

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



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

	return res;

}



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

{

	int res = P2[x2][y2];

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

	res -= P2[x2][y1];



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

	return res;

}



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

{

	int res = P3[x2][y2];

	res -= P3[x1][y2];

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



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

	return res;

}



void print(int n, int m, int P[MAX][MAX])

{

	FOR(i, 0, n)

	{

		FOR(j, 0, m) cout << P[i][j] << " ";

		cout << endl;

	}

}



int main()

{

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

	//freopen("out.txt", "w", stdout);

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

	int n, m, q;

	cin >> n >> m >> q;

	FOR(i, 0, n)

	{

		cin >> A[i];

	}



	FOR(i, 0, n)

	{

		FOR(j, 0, m)

		{

			P1[i][j] = A[i][j] == '1';

			recalc(i, j, P1);

		}

	}



	FOR(i, 0, n)

	{

		FOR(j, 0, m)

		{

			if (j && A[i][j] == A[i][j - 1] && A[i][j] == '1')

			{

				P2[i][j] = 1;

			}

			

			recalc(i, j, P2);

		}

	}



	FOR(i, 0, n)

	{

		FOR(j, 0, m)

		{

			if (i && A[i][j] == A[i - 1][j] && A[i][j] == '1')

			{

				P3[i][j] = 1;

			}



			recalc(i, j, P3);

		}

	}



	//print(n,m,P1);

	//cout << endl;

	//print(n, m, P2);

	//cout << endl;

	//print(n, m, P3);



	FOR(i, 0, q)

	{

		int x1, y1, x2, y2;

		cin >> x1 >> y1 >> x2 >> y2;



		x1--;

		y1--;

		x2--;

		y2--;



		int p1 = get1(x1, y1, x2, y2);

		int p2 = get2(x1, y1, x2, y2);

		int p3 = get3(x1, y1, x2, y2);

		

		//cout <<"!!" << p1 << " " << p2 << " " << p3 << endl;

		cout << p1 - (p2 + p3) << endl;

	}

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MN 2005

using namespace std;

inline int in(){

    int x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

bool s[MN][MN];

char ch[MN];

int s1[MN][MN],s2[MN][MN],f[MN][MN],sum[MN][MN];

int n,m,q,xa,ya,xb,yb,res;

int main()

{

	n=in();m=in();q=in();

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

		scanf("%s",ch);

		for (int j=0;j<m;++j) s[i][j+1]=ch[j]-'0';

	}

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

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

			s1[i][j]=s1[i][j-1]+(s[i][j]&&s[i-1][j]);

			s2[i][j]=s2[i-1][j]+(s[i][j]&&s[i][j-1]); 

			f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]&&s[i-1][j])+(s[i][j]&&s[i][j-1]);

			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]);

		}

	}

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

		xa=in();ya=in();xb=in();yb=in();

		res=sum[xb][yb]-sum[xa-1][yb]-sum[xb][ya-1]+sum[xa-1][ya-1];

		res-=f[xb][yb]-f[xa-1][yb]-f[xb][ya-1]+f[xa-1][ya-1];

		res+=s1[xa][yb]+s2[xb][ya]-s1[xa][ya-1]-s2[xa-1][ya];printf("%d\n",res);

	}

	return 0;

}

// Fastest known solution for this problem: