#include <cstdio>

typedef long long ll;

const int MAX_N = 2000, MAX_M = 2000; 
ll N, M, Q;
int s[MAX_N + 2][MAX_M + 2];

ll node[MAX_N + 2][MAX_M + 2];
ll left[MAX_N + 2][MAX_M + 2];
ll upper[MAX_N + 2][MAX_M + 2];

int main()
{
    scanf("%lld %lld %lld", &N, &M, &Q);
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            char c;
            scanf(" %c", &c);
            if(c == '1'){
                s[i][j] = 1;
            }else{
                s[i][j] = 0;
            }
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            node[i][j] = node[i][j - 1] + node[i - 1][j] - node[i - 1][j - 1] + s[i][j];
            upper[i][j] = upper[i][j - 1] + upper[i - 1][j] - upper[i - 1][j - 1];
            left[i][j] = left[i][j - 1] + left[i - 1][j] - left[i - 1][j - 1];
            if(s[i][j] == 1){
                if(s[i - 1][j] == 1){
                    upper[i][j]++;
                }
                if(s[i][j - 1] == 1){
                    left[i][j]++;
                }
            }
        }
    }
    for(int k = 1; k <= Q; k++){
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int n = node[x2][y2] - node[x1 - 1][y2] - node[x2][y1 - 1] + node[x1 - 1][y1 - 1];
        int e = upper[x2][y2] - upper[x1][y2] - upper[x2][y1 - 1] + upper[x1][y1 - 1];
        e += left[x2][y2] - left[x1 - 1][y2] - left[x2][y1] + left[x1 - 1][y1];
        printf("%d\n", n - e);
    }
}
