#include<bits/stdc++.h>
using namespace std;
#define ran 2222
int row,col;
int a[ran][ran];
int R[ran][ran];
int C[ran][ran];
int sub(int a[ran][ran], int X1,int Y1,int X2,int Y2){
	if(X1 > X2 || Y1 > Y2)return 0;
	--X1;--Y1;
	return a[X1][Y1] + a[X2][Y2] - a[X1][Y2] - a[X2][Y1];
}
int main(){
	int q;
	char s[ran];
	scanf("%d%d%d",&row,&col,&q);
	for(int i=1; i<=row; i++){
		scanf("%s",s);
		for(int j=1; j<=col; j++)
			if(s[j-1] == '1')
				a[i][j] = 1;
	}
	for(int i=1; i<=row; i++)
		for(int j=1; j<=col; j++){
			if(i<row && a[i][j] == 1 && a[i+1][j] == 1)
				R[i][j] = 1;
			if(j<col && a[i][j] == 1 && a[i][j+1] == 1)
				C[i][j] = 1;
		}
	for(int i=1; i<=row; i++)
		for(int j=1; j<=col; j++){
			R[i][j] += R[i][j-1];
			C[i][j] += C[i][j-1];
			a[i][j] += a[i][j-1];
		}
	for(int i=1; i<=row; i++)
		for(int j=1; j<=col; j++){
			R[i][j] += R[i-1][j];
			C[i][j] += C[i-1][j];
			a[i][j] += a[i-1][j];
		}
	while(q--){
		int X1,Y1,X2,Y2;
		scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
		printf("%d\n",sub(a, X1,Y1,X2,Y2) -
		sub(R, X1, Y1, X2-1, Y2) - sub(C, X1, Y1, X2, Y2-1));
	}
	return 0;
}
