#include <bits/stdc++.h>

// limit
#define oo 1000000007
#define OO 10000000000000007LL
#define maxN 2005

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define iii tuple <int, int, int>
#define iiii tuple <int, int, int, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

ll Max() {return -OO;}
ll Min() {return  OO;}

template <typename... Args>
ll Max(ll a, Args... args) {return max(a, Max(args...));}

template <typename... Args>
ll Min(ll a, Args... args) {return min(a, Min(args...));}

int f[maxN][maxN], _f[maxN][maxN], a[maxN][maxN];
int F[maxN][maxN], F2[maxN][maxN], _F[maxN][maxN], down[maxN][maxN];

int main() {

    int n, m, q;
    scanf("%d%d%d", &n, &m, &q);

    fto (i, 1, n) {
        string s;
        cin >> s;
        fto (j, 1, m) a[i][j] = s[j-1]-'0';
    }

    fto (i, 1, n) {
        fto (j, 1, m) f[i][j] = f[i][j-1]+a[i][j];
    }

    fto (j, 1, m) {
        fto (i, 1, n) _f[i][j] = _f[i-1][j]+f[i][j];
    }

    fto (i, 1, n) {
        fto (j, 1, m) F2[i][j] = F2[i-1][j]+(a[i][j] && a[i][j-1]);
    }

    fto (i, 1, n) {
        fto (j, 1, m) F[i][j] = F[i][j-1]+(a[i][j] && a[i][j-1]);
    }

    fto (i, 1, n) {
        fto (j, 1, m) {
            down[i][j] = down[i][j-1]+(a[i][j] && a[i-1][j]);
        }
    }

    fto (j, 1, m) {
        fto (i, 1, n) _F[i][j] = _F[i-1][j]+F[i][j]+down[i][j];
    }

    fto (i, 1, q) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        int num = _f[x2][y2]-_f[x2][y1-1]-_f[x1-1][y2]+_f[x1-1][y1-1];
        int vec = _F[x2][y2]-_F[x2][y1-1]-_F[x1-1][y2]+_F[x1-1][y1-1];

        int cnt = 0;
        fto (i, x1, x2) if (a[i][y1] && a[i][y1-1]) ++cnt;

        vec -= down[x1][y2]-down[x1][y1-1];
        vec -= F2[x2][y1]-F2[x1-1][y1];

        if (cnt != F2[x2][y1]-F2[x1-1][y1]) bug("WA");

        printf("%d\n", num-vec);
    }

    return 0;
}


Measured memory_bytes: 111744