#include <iostream>
#include <string>

using namespace std;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    string S[N];
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }

    int vcnt[N + 1][M + 1];
    fill(vcnt[0], vcnt[N + 1], 0);
    // vcnt[i][j] = (1, 1)~(i, j)中の青マスの数
    // vcnt[i][0] = vcnt[0][j] = 0

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            // indexのズレに注意
            vcnt[i + 1][j + 1] = vcnt[i][j + 1] + vcnt[i + 1][j] - vcnt[i][j] + (S[i][j] == '1');
        }
    }

    int ercnt[N + 1][M + 1];
    fill(ercnt[0], ercnt[N + 1], 0);
    // ercnt[i][j] = (1, 1)~(i, j)中での青マスの横連結箇所数(row)

    int eccnt[N + 1][M + 1];
    fill(eccnt[0], ercnt[N + 1], 0);
    // eccnt[i][j] = (1, 1)~(i, j)中での青マスの縦連結箇所数(column)

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            ercnt[i + 1][j + 1] = ercnt[i][j + 1] + ercnt[i + 1][j] - ercnt[i][j];
            ercnt[i + 1][j + 1] += (j > 0 && S[i][j] == '1' && S[i][j - 1] == '1');

            eccnt[i + 1][j + 1] = eccnt[i][j + 1] + eccnt[i + 1][j] - eccnt[i][j];
            eccnt[i + 1][j + 1] += (i > 0 && S[i][j] == '1' && S[i - 1][j] == '1');
        }
    }

    for (int q = 0; q < Q; ++q) {
        int x[2], y[2];
        for (int i = 0; i < 2; ++i) {
            cin >> x[i] >> y[i];
        }

        int v = vcnt[x[1]][y[1]] - vcnt[x[0] - 1][y[1]] - vcnt[x[1]][y[0] - 1] + vcnt[x[0] - 1][y[0] - 1];

        int e = 0;
        e += ercnt[x[1]][y[1]] - ercnt[x[1]][y[0]] - ercnt[x[0] - 1][y[1]] + ercnt[x[0] - 1][y[0]];
        e += eccnt[x[1]][y[1]] - eccnt[x[0]][y[1]] - eccnt[x[1]][y[0] - 1] + eccnt[x[0]][y[0] - 1];

        cout << v - e << endl;
    }

    return 0;
}
#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

//using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
//typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const i64 mod = 1000000007LL ;
#define INF 2000000000001LL
#define maxn 200005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

int Left[2002][2002] , Up[2002][2002] ;
int ones[2002][2002] ;
char s[2005][2005] ;

int main()
{
    int n , m , q ;

    scanf("%d %d %d",&n,&m,&q) ;

    for(int i=1 ; i<=n; i++) scanf("%s",s[i]+1) ;

    for(int i=1; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            if( s[i][j]=='1' ) ones[i][j] = 1 ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            if( ones[i][j] == 1 && ones[i-1][j] == 1 ) Up[i][j] = 1 ;
            if( ones[i][j] == 1 && ones[i][j-1] == 1 ) Left[i][j] = 1 ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            Left[i][j] += Left[i][j-1] ;
            Up[i][j] += Up[i][j-1] ;
        }
        for(int j=1 ; j<=m ; j++)
        {
            Left[i][j] += Left[i-1][j] ;
            Up[i][j] += Up[i-1][j] ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m; j++) ones[i][j] = ones[i][j-1] + ones[i][j] ;
        for(int j=1 ; j<=m; j++) ones[i][j] += ones[i-1][j] ;
    }

    for(int i=1 ; i<=q ; i++)
    {
        int x1 , y1 , x2, y2 ;
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2) ;

        int nodes = ones[x2][y2] - ones[x1-1][y2] - ones[x2][y1-1] + ones[x1-1][y1-1] ;
        int edgesHor = Left[x2][y2] - Left[x1-1][y2] - Left[x2][y1] + Left[x1-1][y1] ;
        int edgesVer = Up[x2][y2] - Up[x1][y2] - Up[x2][y1-1] + Up[x1][y1-1] ;

        printf("%d\n",nodes-edgesHor-edgesVer) ;
    }


    return 0 ;
}
