#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=2005;

int n,m,Q;
int l[MAXN][MAXN],u[MAXN][MAXN],p[MAXN][MAXN];
char s[MAXN][MAXN];

int main(){
    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++){
            l[i][j]=l[i-1][j]+l[i][j-1]-l[i-1][j-1];
            u[i][j]=u[i-1][j]+u[i][j-1]-u[i-1][j-1];
            p[i][j]=p[i-1][j]+p[i][j-1]-p[i-1][j-1];
            if(s[i][j]=='0') continue;
            p[i][j]++;
            if(s[i][j-1]=='1') l[i][j]++;
            if(s[i-1][j]=='1') u[i][j]++;
        }
    while(Q--){
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int point=p[x2][y2]-p[x1-1][y2]-p[x2][y1-1]+p[x1-1][y1-1];
        int edge=l[x2][y2]-l[x1-1][y2]-l[x2][y1]+l[x1-1][y1];
        edge+=u[x2][y2]-u[x1][y2]-u[x2][y1-1]+u[x1][y1-1];
        printf("%d\n",point-edge);
    }
}
