#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vvector<vector<t>>;
template<class t>
using vvvvector = vvvector<vector<t>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){ return modpow(x, MOD-2); }
ll in(){ ll x; scanf("%lld",&x); return x; }
string in_s(){ string res;cin >> res;return res; }
char in_c(){char res;cin>>res;return res;}
char in_digit(){return in_c()-'0';}
bool was_output = false;
template<class t>
void output(t a){ if(was_output)cout << " "; cout << a; was_output = true; }
void outendl(){ was_output = false; cout << endl; }
string outopen = "";
string outclose = "";
string outsplit = " ";
string outenter = "\n";
template<class t>
ostream& operator<<(ostream& os,vector<t> &x){
	if(typeid(t)==typeid(int)||typeid(t)==typeid(long long)||typeid(t)==typeid(char)||typeid(t)==typeid(string)||typeid(t)==typeid(double)){
		bool flag = false;
		os << outopen;
		for(auto i:x){
			if(flag)os << outsplit;
			flag = true;
			os << i;
		}
		os << outclose;
		os << outenter;
		return os;
	}
	os << outopen;
	for(auto i:x){
		os << i;
	}
	os << outclose;
	return os;
}
template<class t>
istream& operator>>(istream &is,vector<t> &x){
	for(auto &i:x){
		is >> i;
	}
	return is;
}

int main(){
    int n;
    int m;
    int q;
    n = in();
    m = in();
    q = in();
    vvector<int> nums(n,vector<int>(m));
    rep(i,n){
        rep(j,m){
            nums[i][j] = in_digit();
        }
    }

    vvector<int> sum(n,vector<int>(m));
    vvector<int> con(n,vector<int>(m,0));
    vvector<int> lcon(n,vector<int>(m,0));
    vvector<int> ucon(n,vector<int>(m,0));


    auto get_num = [&](int i,int j){
        if(i<0||j<0||i>=n||j>=m){
            return 0;
        }
        return nums[i][j];
    };
    auto get_sum = [&](int i,int j){
        if(i<0||j<0||i>=n||j>=m){
            return 0;
        }
        return sum[i][j];
    };
    auto get_con = [&](int i,int j){
        if(i<0||j<0||i>=n||j>=m){
            return 0;
        }
        return con[i][j];
    };
    auto get_lcon = [&](int i,int j){
        if(i<0||j<0||i>=n||j>=m){
            return 0;
        }
        return lcon[i][j];
    };
    auto get_ucon = [&](int i,int j){
        if(i<0||j<0||i>=n||j>=m){
            return 0;
        }
        return ucon[i][j];
    };

    rep(i,n){
        rep(j,m){
            sum[i][j] = get_sum(i,j-1);
            if(get_num(i,j)){
                ++sum[i][j];
            }
        }
    }

    rep(j,m){
        rep(i,n){
            sum[i][j] += get_sum(i-1,j);
        }
    }

    rep(i,n){
        rep(j,m){
            if(get_num(i,j)){
                if(get_num(i-1,j)){
                    ++con[i][j];
                    ++ucon[i][j];
                }
                if(get_num(i,j-1)){
                    ++con[i][j];
                    ++lcon[i][j];
                }
            }
            con[i][j] += get_con(i,j-1);
            ucon[i][j] += get_ucon(i,j-1);
        }
    }
    rep(j,m){
        rep(i,n){
            con[i][j] += get_con(i-1,j);
            lcon[i][j] += get_lcon(i-1,j);
        }
    }

    rep(i,q){
        int x1;
        int y1;
        int x2;
        int y2;
        y1 = in()-1;
        x1 = in()-1;
        y2 = in()-1;
        x2 = in()-1 ;
        int sums = get_sum(y2,x2) - get_sum(y2,x1-1) - get_sum(y1-1,x2) + get_sum(y1-1,x1-1);
        int cons = get_con(y2,x2) - get_con(y2,x1-1) - get_con(y1-1,x2) + get_con(y1-1,x1-1)
            - get_lcon(y2,x1) + get_lcon(y1-1,x1)
            - get_ucon(y1,x2) + get_ucon(y1,x1-1);

        cout << sums - cons << endl;
    }
	return 0;
}


Measured memory_bytes: 80768