import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int n, m, q;
    readVars(n, m, q);
    auto s = new int[][](n, m);

    foreach(i ; 0 .. n){
        auto line = readln.chomp;
        foreach(j, ch; line){
            s[i][j] = ch - '0';
        }
    }

    //stderr.writefln("%(%(%s %)\n%)", s);

    auto sxy = new int[][](n, m);

    foreach(i ; 0 .. n){
        sxy[i][] = s[i][];
    }

    //stderr.writefln("%(%(%s %)\n%)", sxy);

    foreach(i ; 0 .. n){
        foreach(j ; 0 .. m - 1){
            sxy[i][j + 1] += sxy[i][j];
        }
    }

    foreach(j ; 0 .. m){
        foreach(i ; 0 .. n - 1){
            sxy[i + 1][j] += sxy[i][j];
        }
    }

    //stderr.writefln("%(%(%s %)\n%)", sxy);
    //stderr.writefln("%(%(%s %)\n%)", s);

    auto exy = new int[][](2*n, 2*m);

    foreach(i ; 0 .. 2*n - 1){
        if (i % 2 == 0) {
            foreach(j ; 0 .. 2*m - 1){
                exy[i][j + 1] += exy[i][j];

                if (j % 2 == 0 && j < 2*m - 2) {
                    exy[i][j + 1] += (s[i/2][j/2] == 1 && s[i/2][j/2 + 1] == 1);
                }
            }
        }
        else
        {
            foreach(j ; 0 .. 2*m - 1){
                if (j % 2 == 0){
                    exy[i][j] += (s[i/2][j/2] == 1 && s[i/2 + 1][j/2] == 1);
                }

                exy[i][j + 1] += exy[i][j];
            }
        }
    }

    foreach(j ; 0 .. 2*m){
        foreach(i ; 0 .. 2*n - 1){
            exy[i + 1][j] += exy[i][j];
        }
    }

    int x1, x2, y1, y2, nv, ne, ans;

    foreach(qi ; 0 .. q){
        readVars(x1, y1, x2, y2);
        x1--;
        x2--;
        y1--;
        y2--;

        nv = sxy[x2][y2];

        if (x1 - 1 >= 0) nv -= sxy[x1 - 1][y2];
        if (y1 - 1 >= 0) nv -= sxy[x2][y1 - 1];
        if (x1 - 1 >= 0 && y1 - 1 >= 0) nv += sxy[x1 - 1][y1 - 1];

        ne = exy[2*x2][2*y2];

        if (2*x1 - 1 >= 0) ne -= exy[2*x1 - 1][2*y2];
        if (2*y1 - 1 >= 0) ne -= exy[2*x2][2*y1 - 1];
        if (2*x1 - 1 >= 0 && 2*y1 - 1 >= 0) ne += exy[2*x1 - 1][2*y1 - 1];

        ans = nv - ne;

        writeln(ans);
    }
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}