#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
const int MAX_N = 2000;
int S[MAX_N][MAX_N];
int V[MAX_N][MAX_N]; // 頂点(青マス)の個数
int E_v[MAX_N][MAX_N]; // 縦方向に共有する辺の個数
int E_h[MAX_N][MAX_N]; // 横方向に共有する辺の個数
int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < M; j++) {
            S[i][j] = s[j] == '1' ? 1 : 0;
            V[i][j] = S[i][j];
            E_v[i][j] = E_h[i][j] = 0;
            if(i) {
                V[i][j] += V[i - 1][j];
                E_h[i][j] += E_h[i - 1][j];
                E_v[i][j] += E_v[i - 1][j] + (S[i][j] & S[i - 1][j]);
            }
            if(j) {
                V[i][j] += V[i][j - 1];
                E_v[i][j] += E_v[i][j - 1];
                E_h[i][j] += E_h[i][j - 1] + (S[i][j] & S[i][j - 1]);
            }
            if(i && j) {
                V[i][j] -= V[i - 1][j - 1];
                E_v[i][j] -= E_v[i - 1][j - 1];
                E_h[i][j] -= E_h[i - 1][j - 1];
            }
        }
    }
    for(int q = 0; q < Q; q++) {
        int l, r, t, b;
        cin >> t >> l >> b >> r;
        l--, t--, r--, b--;
        int v = 0, ev = 0, eh = 0, ans;
        v += V[b][r];
        ev += E_v[b][r];
        eh += E_h[b][r];
        if(l >= 0) eh -= E_h[b][l];
        if(l > 0) ev -= E_v[b][l - 1];
        if(t >= 0) ev -= E_v[t][r];
        if(t > 0) eh -= E_h[t - 1][r];
        if(l > 0 && t >= 0) ev += E_v[t][l - 1];
        if(l >= 0 && t > 0) eh += E_h[t - 1][l];
        l--, t--;
        if(l >= 0) v -= V[b][l];
        if(t >= 0) v -= V[t][r];
        if(l >= 0 && t >= 0) v += V[t][l];
        ans = v - ev - eh;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 64256