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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

vector<vector<ll>> cumulative_sum_2d(vector<vector<ll>> &X){
    ll H = X.size();
    ll W = X[0].size();
    vector<vector<ll>> S(H+1, vector<ll>(W+1, 0));
    REP(i, H){
        REP(j, W){
            S[i+1][j+1] = S[i+1][j] + X[i][j];
        }
    }
    REP(j, W+1){
        REP(i, H){
            S[i+1][j] += S[i][j];
        }
    }
    return S;
}

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

    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    vector<vector<ll>> A(N, vector<ll>(M, 0));
    vector<vector<ll>> Y(N, vector<ll>(M-1, 0));
    vector<vector<ll>> T(N-1, vector<ll>(M, 0));

    REP(i, N){
        REP(j, M){
            A[i][j] = S[i][j] - '0';
        }
    }

    if(M>1){
        REP(i, N){
            REP(j, M-1){
                if(S[i][j]=='1' and S[i][j+1]=='1') Y[i][j] = 1;
            }
        }
    }

    if(N>1){
        REP(j, M){
            REP(i, N-1){
                if(S[i][j]=='1' and S[i+1][j]=='1') T[i][j] = 1;
            }
        }
    }

    vector<vector<ll>> SA, SY, ST;
    SA = cumulative_sum_2d(A);
    if(M>1) SY = cumulative_sum_2d(Y);
    if(N>1) ST = cumulative_sum_2d(T);

    // cout << A << endl;
    // cout << endl;
    // cout << Y << endl;
    // cout << endl;
    // cout << T << endl;
    // cout << endl;

    // cout << SA << endl;
    // cout << endl;
    // cout << SY << endl;
    // cout << endl;
    // cout << ST << endl;
    // cout << endl;

    while(Q--){
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--, y1--, x2--, y2--;
        ll res = 0;
        res += SA[x2+1][y2+1] + SA[x1][y1] - SA[x2+1][y1] - SA[x1][y2+1];
        if(M>1) res -= SY[x2+1][y2] + SY[x1][y1] - SY[x2+1][y1] - SY[x1][y2];
        if(N>1) res -= ST[x2][y2+1] + ST[x1][y1] - ST[x2][y1] - ST[x1][y2+1];
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 195380