#include "bits/stdc++.h"
using namespace std;
const int N = 2e3 + 3;
int n , m , q;
char str[N][N];
int sum0[N][N];
int sum1[N][N];
int sum2[N][N];
int sum(int pre[N][N] , int x1 , int y1 , int x2 , int y2){
    return pre[x2][y2] - pre[x1 - 1][y2] - pre[x2][y1 - 1] + pre[x1 - 1][y1 - 1];
}
int main(){
    scanf("%d %d %d" , &n , &m , &q);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%s" , str[i] + 1);
    }
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= m ; ++j){
            sum0[i][j] = sum0[i][j - 1] + sum0[i - 1][j] - sum0[i - 1][j - 1] + (str[i][j] == '1');
            sum1[i][j] = sum1[i][j - 1] + sum1[i - 1][j] - sum1[i - 1][j - 1] + (str[i][j] == '1' && str[i][j - 1] == '1');
            sum2[i][j] = sum2[i][j - 1] + sum2[i - 1][j] - sum2[i - 1][j - 1] + (str[i][j] == '1' && str[i - 1][j] == '1');
        }
    }
    while(q--){
        int x1 , y1 , x2 , y2;
        scanf("%d %d %d %d" , &x1 , &y1 , &x2 , &y2);
        printf("%d\n" , sum(sum0 , x1 , y1 , x2 , y2) - sum(sum1 , x1 , y1 + 1 , x2 , y2) - sum(sum2 , x1 + 1 , y1 , x2 , y2));
    }
}