#include <bits/stdc++.h>
using namespace std;
char s[55][55];
int sum[55][55], cnt[55][55][55][55], ans[55][55][55][55];
bool rec(int i, int j, int k, int h) {
  return sum[k][h] - sum[k][j - 1] - sum[i - 1][h] + sum[i - 1][j - 1] == 0;
}
void input() {
  int i, nq, nh, nc;
  int j, k, h, len1, len2;
  scanf("%d %d %d", &nh, &nc, &nq);
  for ((i) = (1); (i) <= (nh); (i)++) scanf("%s", s[i] + 1);
  for ((i) = (1); (i) <= (nh); (i)++)
    for ((j) = (1); (j) <= (nc); (j)++)
      sum[i][j] =
          sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + s[i][j] - '0';
  for ((i) = (1); (i) <= (nh); (i)++)
    for ((j) = (1); (j) <= (nc); (j)++)
      for ((k) = (i); (k) <= (nh); (k)++)
        for ((h) = (j); (h) <= (nc); (h)++)
          cnt[i][j][k][h] = cnt[i][j][k - 1][h] + cnt[i][j][k][h - 1] -
                            cnt[i][j][k - 1][h - 1] + rec(i, j, k, h);
  for ((len1) = 0; (len1) < (nh); (len1)++)
    for ((len2) = 0; (len2) < (nc); (len2)++)
      for ((i) = (1); (i) <= (nh); (i)++)
        for ((j) = (1); (j) <= (nc); (j)++) {
          k = i + len1;
          h = j + len2;
          ans[i][j][k][h] = ans[i + 1][j][k][h] + ans[i][j + 1][k][h] -
                            ans[i + 1][j + 1][k][h] + cnt[i][j][k][h];
        }
  while (nq--) {
    scanf("%d %d %d %d", &i, &j, &k, &h);
    printf("%d\n", ans[i][j][k][h]);
  }
}
int main() {
  input();
  return 0;
}
