#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<vector<int> > mapa, prsum;
vector<vector<vector<vector<int> > > > memo;
int innul(int x1, int y1, int x2, int y2) {
  return prsum[y2][x2] - prsum[y2][x1] - prsum[y1][x2] + prsum[y1][x1];
}
int slv(int x1, int y1, int x2, int y2);
int solve(int a, int b, int c, int d) {
  ;
  ;
  ;
  ;
  if (memo[a][b][c][d] == -1) {
    int x1 = b, x2 = d + 1, y1 = a, y2 = c + 1;
    if ((x2 - x1) <= 0 || (y2 - y1) <= 0) {
      memo[a][b][c][d] = 0;
      return 0;
    }
    int res = 0;
    if (innul(x1, y1, x2, y2) == 0) res++;
    res += slv(x1, y1, x2 - 1, y2);
    res += slv(x1, y1, x2, y2 - 1);
    res += slv(x1 + 1, y1, x2, y2);
    res += slv(x1, y1 + 1, x2, y2);
    res -= slv(x1 + 1, y1, x2 - 1, y2);
    res -= slv(x1, y1 + 1, x2, y2 - 1);
    res -= slv(x1, y1, x2 - 1, y2 - 1);
    res -= slv(x1 + 1, y1, x2, y2 - 1);
    res -= slv(x1 + 1, y1 + 1, x2, y2);
    res -= slv(x1, y1 + 1, x2 - 1, y2);
    res += slv(x1, y1 + 1, x2 - 1, y2 - 1);
    res += slv(x1 + 1, y1, x2 - 1, y2 - 1);
    res += slv(x1 + 1, y1 + 1, x2, y2 - 1);
    res += slv(x1 + 1, y1 + 1, x2 - 1, y2);
    res -= slv(x1 + 1, y1 + 1, x2 - 1, y2 - 1);
    memo[a][b][c][d] = res;
  }
  return memo[a][b][c][d];
}
int slv(int x1, int y1, int x2, int y2) {
  if ((x2 - x1) <= 0 || (y2 - y1) <= 0) return 0;
  return solve(y1, x1, y2 - 1, x2 - 1);
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  mapa.resize(n, vector<int>(m));
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < m; x++) {
      char c;
      scanf(" %c", &c);
      mapa[y][x] = c - '0';
    }
  };
  prsum.resize(n + 1, vector<int>(m + 1, 0));
  for (int y = 1; y <= n; y++) {
    for (int x = 1; x <= m; x++) {
      prsum[y][x] = prsum[y - 1][x] + prsum[y][x - 1] - prsum[y - 1][x - 1] +
                    mapa[y - 1][x - 1];
    }
  };
  memo.resize(n, vector<vector<vector<int> > >(
                     m, vector<vector<int> >(n, vector<int>(m, -1))));
  for (int i = 0; i < q; i++) {
    ;
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int res = solve(a - 1, b - 1, c - 1, d - 1);
    printf("%d\n", res);
  }
  return 0;
}
