#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, q;
	cin >> n >> m >> q;
	vector<string> a(n);
	rep(i, n) cin >> a[i];
	vector<vector<int>> sum(n + 1, vector<int>(m + 1));
	vector<vector<int>> sum2(n + 1, vector<int>(m + 1));
	vector<vector<int>> sum3(n + 1, vector<int>(m + 1));
	rep(i, n) {
		rep(j, m) {
			sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
			sum2[i + 1][j + 1] = sum2[i + 1][j] + sum2[i][j + 1] - sum2[i][j];
			sum3[i + 1][j + 1] = sum3[i + 1][j] + sum3[i][j + 1] - sum3[i][j];
			if (a[i][j] == '1') sum[i + 1][j + 1]++;
			if (i != 0 && a[i - 1][j] == '1'&&a[i][j] == '1') sum2[i + 1][j + 1]++;
			if (j != 0 && a[i][j - 1] == '1'&&a[i][j] == '1') sum3[i + 1][j + 1]++;
		}
	}
	rep(_, q) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--; y1--;
		int ans = sum[x1][y1] + sum[x2][y2] - sum[x1][y2] - sum[x2][y1];
		ans -= sum2[x1 + 1][y1] + sum2[x2][y2] - sum2[x1 + 1][y2] - sum2[x2][y1];
		ans -= sum3[x1][y1 + 1] + sum3[x2][y2] - sum3[x1][y2] - sum3[x2][y1 + 1];
		cout << ans << '\n';
	}
} 
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL S[2001][2001] = {};
	UL J1[2001][2001] = {};
	UL J2[2001][2001] = {};

	void Query() {
		UL y1, y2, x1, x2; cin >> y1 >> x1 >> y2>> x2;
		y1--; x1--;
		UL mass = S[x2][y2] + S[x1][y1] - S[x1][y2] - S[x2][y1];
		UL J1s = J1[x2][y2] + J1[x1 + 1][y1] - J1[x1 + 1][y2] - J1[x2][y1];
		UL J2s = J2[x2][y2] + J2[x1][y1 + 1] - J2[x1][y2] - J2[x2][y1 + 1];
		cout << (mass - J1s - J2s) << endl;
	}

	void Solve() {
		UL H, W; cin >> H >> W;
		UL Q; cin >> Q;
		rep(y, H) rep(x, W) {
			char c; cin >> c;
			S[x + 1][y + 1] = (c - '0');
		}
		rep(y, H) rep(x, W) if (S[x][y + 1] && S[x + 1][y + 1]) J1[x + 1][y + 1] = 1;
		rep(y, H) rep(x, W) if (S[x + 1][y] && S[x + 1][y + 1]) J2[x + 1][y + 1] = 1;
		rep(y, H) rep(x, W) S[x + 1][y + 1] += S[x][y + 1];
		rep(y, H) rep(x, W) S[x + 1][y + 1] += S[x + 1][y];
		rep(y, H) rep(x, W) J1[x + 1][y + 1] += J1[x][y + 1];
		rep(y, H) rep(x, W) J1[x + 1][y + 1] += J1[x + 1][y];
		rep(y, H) rep(x, W) J2[x + 1][y + 1] += J2[x][y + 1];
		rep(y, H) rep(x, W) J2[x + 1][y + 1] += J2[x + 1][y];
		rep(i, Q) Query();
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}