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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

 

using namespace std;

using namespace __gnu_pbds;

 

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key

 

typedef long long ll;

typedef pair<int,int> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



char a[2111][2111];

int up[2111][2111];

int ri[2111][2111];



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

{

	return (up[x2][y2]-up[x2][y1-1]-up[x1-1][y2]+up[x1-1][y1-1]);

}



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

{

	return (ri[x2][y2]-ri[x2][y1-1]-ri[x1-1][y2]+ri[x1-1][y1-1]);

}



int dp[2011][2011];



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

{

	return (dp[x2][y2]-dp[x2][y1-1]-dp[x1-1][y2]+dp[x1-1][y1-1]);

}



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	int n,m,q;

	cin>>n>>m>>q;

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

	{

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

		{

			cin>>a[i][j];

			if(a[i][j]=='1') dp[i][j]=1;

		}

	}

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

	{

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

		{

			if(a[i][j]=='1'&&a[i+1][j]=='1')

			{

				up[i][j]=1;

			}

		}

	}

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

	{

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

		{

			if(a[i][j]=='1'&&a[i][j+1]=='1')

			{

				ri[i][j]=1;

			}

		}

	}

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

	{

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

		{

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

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

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

		}

	}

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

	{

		int x1,y1,x2,y2;

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

		int V = DP(x1,y1,x2,y2);

		int E = RI(x1,y1,x2,y2-1)+UP(x1,y1,x2-1,y2);

		cout<<V-E<<'\n';

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.091512705744445x):
#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])

		);

	}

}