#include<cstdio>
#include<algorithm>
using namespace std;
char p[2010][2010];
int n, m, Q, S[2010][2010][3];
int Calc(int x1, int y1, int x2, int y2, int ck){
    return S[x2][y2][ck] - S[x1][y2][ck] - S[x2][y1][ck] + S[x1][y1][ck];
}
int main(){
    int i, j, k, x1, x2, y1, y2;
    scanf("%d%d%d",&n,&m,&Q);
    for(i=1;i<=n;i++){
        scanf("%s",p[i]+1);
        for(j=1;j<=m;j++)S[i][j][0] = p[i][j]-'0';
        for(j=1;j<m;j++)S[i][j][1] = (p[i][j+1]-'0')*(p[i][j]-'0');
        if(i!=1)for(j=1;j<=m;j++)S[i-1][j][2] = (p[i][j]-'0')*(p[i-1][j]-'0');
    }
    for(i=1;i<=n;i++)for(j=1;j<=m;j++)for(k=0;k<3;k++)S[i][j][k]+=S[i-1][j][k]+S[i][j-1][k]-S[i-1][j-1][k];
    while(Q--){
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        printf("%d\n",Calc(x1-1,y1-1,x2,y2,0) - Calc(x1-1,y1-1,x2,y2-1,1) - Calc(x1-1,y1-1,x2-1,y2,2));
    }
}