#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> pii;
typedef pair<double,double> dop;
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 (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



signed main()
{
int n,m,q;
std::cin >> n >> m >> q;
std::vector<std::vector<int>> omap(n,std::vector<int>(m,0));
std::vector<std::vector<int>> pathu(n , std::vector<int>(m , 0));//n-1
std::vector<std::vector<int>> pathr(n , std::vector<int>(m , 0));//m-1
std::vector<std::vector<int>> spathu(n + 1 , std::vector<int>(m + 1, 0));//n-1
std::vector<std::vector<int>> spathr(n + 1, std::vector<int>(m + 1, 0));//m-1
std::vector<std::vector<int>> smap(n + 1,std::vector<int>(m + 1,0));

rep(i,n){
    std::string s;
    std::cin >> s;
    rep(j,m){
        if(s[j] == '1'){
            omap[i][j]++;
        }
    }
}

reps(j,m){
    smap[1][j] = omap[0][j - 1];
}
reps(i,n - 1){
    reps(j,m){
        smap[i + 1][j] += smap[i][j] + omap[i][j - 1];
    }
}
reps(j,m - 1){
    reps(i,n){
        smap[i][j + 1] += smap[i][j];
    }
}
for(int i = 1; i < n; i++){
    for(int j = 0; j < m; j++){
        if(omap[i][j] == 1 && omap[i - 1][j] == 1){
            pathu[i - 1][j] = 1;
        }
    }
}
for(int j = 1; j < m; j++){
    for(int i = 0; i < n; i++){
        if(omap[i][j] == 1 && omap[i][j - 1] == 1){
            pathr[i][j - 1] = 1;
        }
    }
}
reps(j,m){
    spathu[1][j] = 0;
}
reps(i,n){
    spathr[i][1] = 0;
}
for(int i = 0; i < n - 1; i++){
    for(int j = 0; j < m; j++){
        spathu[i + 2][j + 1] += spathu[i + 1][j + 1] + pathu[i][j];
    }
}
for(int j = 0; j < m - 1; j++){
    for(int i = 0; i < n; i++){
        spathr[i + 1][j + 2] += spathr[i + 1][j + 1] + pathr[i][j];
    }
}
for(int j = 1; j < m; j++){
    for(int i = 0; i < n; i++){
        spathu[i + 1][j + 1] += spathu[i + 1][j];
    }
}
for(int i = 1; i < n; i++){
    for(int j = 0; j < m; j++){
        spathr[i + 1][j + 1] += spathr[i][j + 1];
    }
}
std::vector<int>out(q);
for(int i = 0; i < q; i++){
    int x1,y1,x2,y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    y1--;
    x2--;
    y2--;
    int psum = smap[x2 + 1][y2 + 1] + smap[x1][y1] - smap[x1][y2 + 1] - smap[x2 + 1][y1];
    int nxsum = spathu[x2 + 1][y2 + 1] + spathu[x1 + 1][y1] - ( spathu[x1 + 1][y2 + 1] + spathu[x2 + 1][y1]);
    int nysum = spathr[x2 + 1][y2 + 1] + spathr[x1][y1 + 1] - ( spathr[x1][y2 + 1] + spathr[x2 + 1][y1 + 1]);
    out[i] = psum - (nxsum + nysum);
}
for(int i = 0; i < q; i++){
    std::cout << out[i] << std::endl;
}
return 0;
}

Measured memory_bytes: 192640