#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e3 + 3;
int s[MAXN][MAXN], v[MAXN][MAXN], e[MAXN][MAXN], romokh[2][MAXN][MAXN];
int n, m, q;
int a1, a2, b1, b2;

void input();
void cm_romokh();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	return 0;
}

void input() {
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			s[i][j] = c - '0';
			//cout << s[i][j] << endl;
			if (i == 0 && j == 0) v[i][j] = (s[i][j] == 1);
			else if (i == 0) {
				v[i][j] = v[i][j - 1] + (s[i][j] == 1);
				e[i][j] = e[i][j - 1] + (s[i][j] == s[i][j - 1] && s[i][j] == 1);
			}
			else if (j == 0) {
				v[i][j] = v[i - 1][j] + (s[i][j] == 1);
				e[i][j] = e[i - 1][j] + (s[i][j] == s[i - 1][j] && s[i][j] == 1);
			}
			else {
				v[i][j] = v[i][j - 1] + v[i - 1][j] - v[i - 1][j - 1] + (s[i][j] == 1);
				e[i][j] = e[i][j - 1] + e[i - 1][j] - e[i - 1][j - 1] + (s[i][j] == 1 && s[i][j] == s[i - 1][j]) + (s[i][j] == 1 && s[i][j] == s[i][j - 1]);
			}
		}
	cm_romokh();
	//cout << romokh[1][1][2];
	while (q--) {
		cin >> a1 >> b1 >> a2 >> b2;
		if (a1 > a2) swap(a1, a2);
		if (b1 > b2) swap(b1, b2);
		a1--, a2--, b1--, b2--;
		solve();
	}
}

void cm_romokh() {
	for (int i = 1; i < n; i++) {
		romokh[0][i][0] = (s[i][0] == s[i - 1][0] && s[i][0] == 1);
		for (int j = 1; j < m; j++)
			romokh[0][i][j] = romokh[0][i][j - 1] + (s[i][j] == s[i - 1][j] && s[i][j] == 1);
	}
	for (int i = 1; i < m; i++) {
		romokh[1][0][i] = (s[0][i] == s[0][i - 1] && s[0][i] == 1);
		for (int j = 1; j < n; j++)
			romokh[1][j][i] = romokh[1][j - 1][i] + (s[j][i] == s[j][i - 1] && s[j][i] == 1);
	}
}

void solve() {
	int te = 0, tv = 1;
	if (a1 == 0 && b1 == 0) {
		tv = v[a2][b2];
		te = e[a2][b2];
	}
	else if (a1 == 0) {
		tv = v[a2][b2] - v[a2][b1 - 1];
		te = e[a2][b2] - e[a2][b1 - 1] - romokh[1][a2][b1];
	}
	else if (b1 == 0) {
		tv = v[a2][b2] - v[a1 - 1][b2];
		te = e[a2][b2] - e[a1 - 1][b2] - romokh[0][a1][b2];
	}
	else {
		tv = v[a2][b2] + v[a1 - 1][b1 - 1] - v[a1 - 1][b2] - v[a2][b1 - 1];
		te = e[a2][b2] + e[a1 - 1][b1 - 1] - e[a1 - 1][b2] - e[a2][b1 - 1];
		te -= romokh[0][a1][b2] - romokh[0][a1][b1 - 1];
		te -= romokh[1][a2][b1] - romokh[1][a1 - 1][b1];
	}
	cout << tv - te << endl;
}

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M>>Q;
    vector<string> grid(N);
    rep(i,N) cin>>grid[i];
    mat edge(N, vec(M, 0)), num(N + 1, vec(M + 1, 0)), addr(N, vec(M,0)), addc(N, vec(M,0));
    rep(i,N){
        rep(j,M){
            bool blue = grid[i][j] == '1';
            if(i > 0) {
                edge[i][j] += edge[i-1][j] + (blue && grid[i-1][j] == '1');
                addc[i][j] = addc[i-1][j] + (blue && grid[i-1][j] == '1');
            }
            if(j > 0) {
                edge[i][j] += edge[i][j-1] + (blue && grid[i][j-1] == '1');
                addr[i][j] = addr[i][j-1] + (blue && grid[i][j-1] == '1');
            }
            if(i > 0 && j > 0) edge[i][j] -= edge[i-1][j-1];
            num[i+1][j+1] = num[i][j+1] + num[i+1][j] - num[i][j] + blue;
        }
    }
    vec x(2), y(2);
    rep(i,Q){
        rep(j,2) cin>>x[j]>>y[j];
        --x[0], --y[0];
        ll res = 0;
        rep(j,2) rep(k,2) res += (j^k ? -1 : 1) * num[x[j]][y[k]];
        --x[1], --y[1];
        rep(j,2) rep(k,2) res += (j^k ? 1 : -1) * edge[x[j]][y[k]];
        res -= addr[x[0]][y[1]] - addr[x[0]][y[0]];
        res -= addc[x[1]][y[0]] - addc[x[0]][y[0]];
        cout<<res<<endl;
    }
    /*rep(i,N){
        rep(j,M) cout<<edge[i][j]<<' ';
        cout<<endl;
    }*/
}