#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

#define left qwteq
#define right lkgjpw

const int MAXN = 2005;

const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};

char mat[MAXN][MAXN];
int ed[MAXN][MAXN];
int left[MAXN][MAXN];
int right[MAXN][MAXN];
int up[MAXN][MAXN], down[MAXN][MAXN];
int cnt[MAXN][MAXN];

int query(int x1, int y1, int x2, int y2) {
    int ret = ed[x2][y2];
    ret -= ed[x1 - 1][y2];
    ret -= ed[x2][y1 - 1];
    ret += ed[x1 - 1][y1 - 1];
//printf("initially: %d\n", ret);
    ret -= left[x2][y1] - left[x1 - 1][y1];
    ret -= right[x2][y2] - right[x1 - 1][y2];

    ret -= up[x1][y2] - up[x1][y1 - 1];
    ret -= down[x2][y2] - down[x2][y1 - 1];

    ret /= -2;

    ret += cnt[x2][y2];
    ret -= cnt[x1 - 1][y2];
    ret -= cnt[x2][y1 - 1];
    ret += cnt[x1 - 1][y1 - 1];

    return ret;
}

int main() {
    //freopen("", "rt", stdin);
    //freopen("", "wt", stdout);
    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 1; i <= n; i++)
        scanf("%s", mat[i] + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            for (int k = 0; k < 4; k++)
                if (mat[i][j] == '1' && mat[i][j] == mat[i + dx[k]][j + dy[k]])
                    ed[i][j]++;
            ed[i][j] += ed[i][j - 1];
            ed[i][j] += ed[i - 1][j];
            ed[i][j] -= ed[i - 1][j - 1];

            cnt[i][j] = (mat[i][j] == '1');
            cnt[i][j] += cnt[i - 1][j];
            cnt[i][j] += cnt[i][j - 1];
            cnt[i][j] -= cnt[i - 1][j - 1];
        }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            left[i][j] = left[i - 1][j];
            if (mat[i][j] == '1' && mat[i][j] == mat[i][j - 1])
                left[i][j]++;
            right[i][j] = right[i - 1][j];
            if (mat[i][j] == '1' && mat[i][j] == mat[i][j + 1])
                right[i][j]++;

            up[i][j] = up[i][j - 1];
            if (mat[i][j] == '1' && mat[i][j] == mat[i - 1][j])
                up[i][j]++;
            down[i][j] = down[i][j - 1];
            if (mat[i][j] == '1' && mat[i][j] == mat[i + 1][j])
                down[i][j]++;
        }
    }
    while (q--) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        printf("%d\n", query(x1, y1, x2, y2));
        /*int e = query(x1, y1, x2, y2) / 2;
        int v = (x2 - x1 + 1) * (y2 - y1 + 1);
        printf("%d\n", v - e);*/
    }
    return 0;
}



Measured memory_bytes: 99968