#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;

int a[2001][2001]={};
int x[2001][2001]={};
int y[2001][2001]={};

int main(){
	int n,m,q;
	cin >> n >> m >> q;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1][j-1]=='1'){
				a[i][j]+=1;
			}
			a[i][j] += a[i][j-1]+a[i-1][j]-a[i-1][j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=2;j<=m;j++){
			if(s[i-1][j-2]=='1'&&s[i-1][j-1]=='1'){
				x[i][j]+=1;
			}
			x[i][j] += x[i][j-1]+x[i-1][j]-x[i-1][j-1];
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-2][j-1]=='1'&&s[i-1][j-1]=='1'){
				y[i][j]+=1;
			}
			y[i][j] += y[i][j-1]+y[i-1][j]-y[i-1][j-1];			
		}
	}
	int x1,x2,y1,y2;
	int ans;
	for(int i=0;i<q;i++){
		cin >> x1 >> y1 >> x2 >> y2;
		ans =0;
		ans += a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
		ans -= x[x2][y2]-x[x1-1][y2]-x[x2][y1]+x[x1-1][y1]; 
		ans -= y[x2][y2]-y[x1][y2]-y[x2][y1-1]+y[x1][y1-1];
		cout << ans << endl;
	}
	return 0;
}