#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 4010
#define Maxm 4010

using namespace std;

int read() {
	int x = 0,f = 1;
	char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while('0' <= c && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}

int N,M,Q;
int mp[Maxn][Maxm],sum1[Maxn][Maxm],sum2[Maxn][Maxm];

int main() {
	N = read(); M = read(); Q = read();
	char ch;
	for(int i = 1;i <= N; i++)
		for(int j = 1;j <= M; j++) {
			int x = i * 2 - 1,y = j * 2 - 1;
			ch = getchar();
			while(ch != '0' && ch != '1') ch = getchar();
			if(ch == '1') mp[x][y] = 1;
		}
	for(int i = 1;i <= N; i++)
		for(int j = 1;j <= M; j++) {
			int x = i * 2 - 1,y = j * 2 - 1;
			if(mp[x][y]) {
				if(mp[x - 2][y]) mp[x - 1][y] = 2;
				if(mp[x + 2][y]) mp[x + 1][y] = 2;
				if(mp[x][y + 2]) mp[x][y + 1] = 2;
				if(mp[x][y - 2]) mp[x][y - 1] = 2;
			}
		}
	for(int i = 1;i < N * 2; i++)
		for(int j = 1;j < M * 2; j++) {
			if(mp[i][j] == 1) sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] + 1;
			else sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1];
			if(mp[i][j] == 2) sum2[i][j] = sum2[i - 1][j] + sum2[i][j - 1] - sum2[i - 1][j - 1] + 1;
			else sum2[i][j] = sum2[i - 1][j] + sum2[i][j - 1] - sum2[i - 1][j - 1];
		}
	int i_1,j_1,i_2,j_2,x_1,y_1,x_2,y_2;
	for(int k = 1;k <= Q; k++) {
		i_1 = read(); j_1 = read(); i_2 = read(); j_2 = read();
		x_1 = i_1 * 2 - 1; y_1 = j_1 * 2 - 1;
		x_2 = i_2 * 2 - 1; y_2 = j_2 * 2 - 1;
		int ans1 = sum1[x_2][y_2] + sum1[x_1 - 1][y_1 - 1] - sum1[x_2][y_1 - 1] - sum1[x_1 - 1][y_2];
		int ans2 = sum2[x_2][y_2] + sum2[x_1 - 1][y_1 - 1] - sum2[x_2][y_1 - 1] - sum2[x_1 - 1][y_2];
		printf("%d\n",ans1 - ans2);
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, M, Q;
	cin >> N >> M >> Q;
	string S[2000];
	rep(i, N) cin >> S[i];
	int B[2001][2001] = {};
	int C[2001][2001] = {};
	int D[2001][2001] = {};
	rep(i, N) {
		rep(j, M) {
			B[i + 1][j + 1] = B[i + 1][j] + S[i][j] - '0';
			if (i != 0) C[i + 1][j + 1] = C[i + 1][j] + ((S[i - 1][j] - '0') & (S[i][j] - '0'));
			if (j != 0) D[i + 1][j + 1] = D[i + 1][j] + ((S[i][j - 1] - '0') & (S[i][j] - '0'));
		}
	}
	rep(j, M) rep(i, N) {
		B[i + 1][j + 1] += B[i][j + 1];
		C[i + 1][j + 1] += C[i][j + 1];
		D[i + 1][j + 1] += D[i][j + 1];
	}
	
	rep(q, Q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int kotae;
		kotae = B[c][d] - B[c][b - 1] - B[a - 1][d] + B[a - 1][b - 1];
		kotae -= C[c][d] - C[c][b - 1] - C[a][d] + C[a][b - 1];
		kotae -= D[c][d] - D[c][b] - D[a - 1][d] + D[a - 1][b];
		co(kotae);
	}

	Would you please return 0;
}