#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#define F(i, a, b) for(register int i = a; i <= b; ++i)
#define D(i, a, b) for(register int i = a; i >= b; --i)
#define E(e, u)    for(int e = hd[u]; e; e = nxt[e])
#define EV(e, u)   for(int e = hd[u], vv; vv = v[e], e; e = nxt[e])
#define Imax(a, b) ((a) > (b) ? (a) : (b))
#define Imin(a, b) ((a) < (b) ? (a) : (b))
#define Iswap(a, b) (a ^= b ^= a ^= b)
#define debug(x) cout<<x<<
#define re register
#define endl '\n'
#define Isdigit(ch) (ch >= '0' && ch <= '9')
#define Change(x) ((x<<1) + (x<<3) + (ch^48))
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<17, stdin), p1 == p2) ? EOF : *p1++)
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef double db;
const int N = 3005;
const int INF = 0x7f7f7f7f;
char buf[1<<17], *p1 = buf, *p2 = buf;
using namespace std;

struct FastIO{
    FastIO(){};
    inline FastIO& operator>>(register char& ch){
        ch = getchar();
        while(ch ^ '1' && ch ^ '0') ch = getchar();
        return *this;
    }
    inline FastIO& operator>>(register double& x){
        x = 0; register bool f = 0; register char ch = getchar();
        double d = 0.1;
        while(!Isdigit(ch)) f |= (ch == '-'), ch = getchar();
        while(Isdigit(ch)) x = x*10 + (ch^48), ch = getchar();
        if(ch == '.') while(isdigit(ch = getchar())) x += d*(ch^48), d*=0.1;
        return x = f ? -x : x, *this;
    }
    template <typename T>inline FastIO& operator>>(register T& x){
        x = 0; register bool f = 0; register char ch = getchar();
        while(!Isdigit(ch)) f |= (ch == '-'), ch = getchar();
        while(Isdigit(ch)) x = Change(x), ch = getchar();
        return x = f ? -x : x, *this;
    }
    inline FastIO& operator<<(register char x){
        return putchar(x), *this;
    }
    template <typename T>inline FastIO& operator<<(register T x){
        if(x < 0) putchar('-'), x = -x;
        register ul _ = 10;
        while(_ <= x) _ *= 10;
        while(_ ^ 1) _ /= 10, putchar(x/_ + 48), x %= _;
        return putchar('\n'), *this;
    }
}io;

template <typename T> inline T Cmin(register T a, register T b){
    return a < b ? a : b;
}

template <typename T> inline T Cmax(register T a, register T b){
    return a > b ? a : b;
}

int x, n, m, q, a1, a2, b1, b2, a[N][N];
LL sumd[N][N], sumb1[N][N], sumb2[N][N];
char ch;

int main(){
    io >> n >> m >> q;
    F(i, 1, n){
        F(j, 1, m) {
            io >> ch;
            x = ch - '0';
            a[i][j] = x;
            sumd[i][j] = sumd[i][j-1] + sumd[i-1][j] - sumd[i-1][j-1] + x;
            sumb1[i][j] = sumb1[i][j-1] + sumb1[i-1][j] - sumb1[i-1][j-1];
            sumb2[i][j] = sumb2[i][j-1] + sumb2[i-1][j] - sumb2[i-1][j-1];
            if(x) {
                if(a[i - 1][j]) ++sumb1[i][j];
                if(a[i][j - 1]) ++sumb2[i][j];
            }
        }
    }
    while(q--){
        io >> a1 >> b1 >> a2 >> b2;
        io << ((sumd[a2][b2] - sumd[a2][b1-1] - sumd[a1-1][b2] + sumd[a1-1][b1-1]) - (sumb1[a2][b2] - sumb1[a1][b2] - sumb1[a2][b1-1] + sumb1[a1][b1-1] + sumb2[a2][b2] - sumb2[a2][b1] - sumb2[a1-1][b2] + sumb2[a1-1][b1]));
    }
    return 0;
}

Measured memory_bytes: 168192