#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define PII pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);

const int maxn = 2e3 + 30;
string a[maxn];
int vertex[maxn][maxn] , er[maxn][maxn] , ed[maxn][maxn];

int main() {
    int n , m , q;
    cin >> n >> m >> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if(a[i - 1][j - 1] == '1') {
                vertex[i][j]++;
            }
            vertex[i][j] += vertex[i - 1][j] + vertex[i][j - 1] - vertex[i - 1][j - 1];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            // if(a[i - 1][j - 1] == '1' && a[i - 2][j - 1] == '1') {
            //     ed[i][j]++;
            // }
            if(a[i - 1][j - 1] == '1' && a[i][j - 1] == '1') {
                ed[i][j]++;
            }
            ed[i][j] += ed[i - 1][j] + ed[i][j - 1] - ed[i - 1][j - 1]; 
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            // if(a[i - 1][j - 1] == '1' && a[i - 1][j - 2] == '1') {
            //     er[i][j]++;
            // }
            if(a[i - 1][j - 1] == '1' && a[i - 1][j] == '1') {
                er[i][j]++;
            }
            er[i][j] += er[i - 1][j] + er[i][j - 1] - er[i - 1][j - 1]; 
        }
    }
    while(q--) {
        int x1 , y1 , x2 , y2;
        ll p1 = 0 , p2 = 0;
        cin >> x1 >> y1 >> x2 >> y2;
        p1 = vertex[x2][y2] - vertex[x2][y1 - 1] - vertex[x1 - 1][y2] + vertex[x1 - 1][y1 - 1];
        p2 += ed[x2 - 1][y2] - ed[x2 - 1][y1 - 1] - ed[x1 - 1][y2] + ed[x1 - 1][y1 - 1];
        p2 += er[x2][y2 - 1] - er[x1 - 1][y2 - 1] - er[x2][y1 - 1] + er[x1 - 1][y1 - 1];
        cout << p1 - p2 << 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;
    }*/
}