#include <bits/stdc++.h>
using namespace std;
__inline bool nextInt(int &val) {
  char ch;
  int sgn = 1;
  while ((ch = getchar()) != EOF) {
    if (ch == '-') sgn = -1;
    if (ch >= '0' && ch <= '9') break;
  }
  if (ch == EOF) return false;
  val = (int)(ch - '0');
  while (true) {
    ch = getchar();
    if (ch >= '0' && ch <= '9') {
      val = 10 * val + (int)(ch - '0');
    } else
      break;
  }
  val *= sgn;
  return true;
}
__inline bool nextString(string &s) {
  char ch;
  while ((ch = getchar()) != EOF) {
    if (ch >= 33 && ch <= 126) break;
  }
  if (ch == EOF) return false;
  s = string(1, ch);
  while (true) {
    ch = getchar();
    if (ch >= 33 && ch <= 126) {
      s = s + string(1, ch);
    } else
      break;
  }
  return true;
}
int n, m, q, s[44][44], dp[44][44][44][44];
char row[44][44];
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d%d%d", &n, &m, &q);
  for (int r = 0; r < (n); r++) scanf("%s", row + r);
  for (int r = 0; r < (n); r++)
    for (int c = 0; c < (m); c++)
      s[r][c] =
          ((r) >= (0) && (c - 1) >= (0)
               ? (((r) >= 0 && (c - 1) >= 0 ? s[r][c - 1] : 0) -
                  (((0) - 1) >= 0 && (c - 1) >= 0 ? s[(0) - 1][c - 1] : 0) -
                  ((r) >= 0 && ((0) - 1) >= 0 ? s[r][(0) - 1] : 0) +
                  (((0) - 1) >= 0 && ((0) - 1) >= 0 ? s[(0) - 1][(0) - 1] : 0))
               : 0) +
          ((r - 1) >= (0) && (c) >= (c)
               ? (((r - 1) >= 0 && (c) >= 0 ? s[r - 1][c] : 0) -
                  (((0) - 1) >= 0 && (c) >= 0 ? s[(0) - 1][c] : 0) -
                  ((r - 1) >= 0 && ((c)-1) >= 0 ? s[r - 1][(c)-1] : 0) +
                  (((0) - 1) >= 0 && ((c)-1) >= 0 ? s[(0) - 1][(c)-1] : 0))
               : 0) +
          ((int)(row[r][c] - '0'));
  memset(dp, 0, sizeof(dp));
  ;
  for (int r1 = 0; r1 < (n); r1++)
    for (int c1 = 0; c1 < (m); c1++)
      for (int r2 = 0; r2 < (n); r2++)
        for (int c2 = 0; c2 < (m); c2++) {
          if (((r2) >= (r1) && (c2) >= (c1)
                   ? (((r2) >= 0 && (c2) >= 0 ? s[r2][c2] : 0) -
                      (((r1)-1) >= 0 && (c2) >= 0 ? s[(r1)-1][c2] : 0) -
                      ((r2) >= 0 && ((c1)-1) >= 0 ? s[r2][(c1)-1] : 0) +
                      (((r1)-1) >= 0 && ((c1)-1) >= 0 ? s[(r1)-1][(c1)-1] : 0))
                   : 0) == 0) {
            dp[r1][c1][r2][c2]++;
          } else {
            break;
          }
        }
  for (int dr = (1); dr < (n + 1); dr++)
    for (int dc = (1); dc < (m + 1); dc++) {
      for (int r = 0; r < (n); r++)
        if (r + dr - 1 < n) {
          int xr = r + dr - 1;
          for (int c = 0; c < (m); c++)
            if (c + dc - 1 < m) {
              int xc = c + dc - 1;
              dp[r][c][xr][xc] +=
                  ((xr) >= (r + 1) && (xc) >= (c) && (xr) < n && (xc) < m &&
                           (r + 1) >= 0 && (c) >= 0
                       ? dp[r + 1][c][xr][xc]
                       : 0) +
                  ((xr) >= (r) && (xc) >= (c + 1) && (xr) < n && (xc) < m &&
                           (r) >= 0 && (c + 1) >= 0
                       ? dp[r][c + 1][xr][xc]
                       : 0) +
                  ((xr - 1) >= (r) && (xc) >= (c) && (xr - 1) < n && (xc) < m &&
                           (r) >= 0 && (c) >= 0
                       ? dp[r][c][xr - 1][xc]
                       : 0) +
                  ((xr) >= (r) && (xc - 1) >= (c) && (xr) < n && (xc - 1) < m &&
                           (r) >= 0 && (c) >= 0
                       ? dp[r][c][xr][xc - 1]
                       : 0) -
                  ((xr - 1) >= (r) && (xc - 1) >= (c) && (xr - 1) < n &&
                           (xc - 1) < m && (r) >= 0 && (c) >= 0
                       ? dp[r][c][xr - 1][xc - 1]
                       : 0) -
                  ((xr - 1) >= (r) && (xc) >= (c + 1) && (xr - 1) < n &&
                           (xc) < m && (r) >= 0 && (c + 1) >= 0
                       ? dp[r][c + 1][xr - 1][xc]
                       : 0) -
                  ((xr) >= (r + 1) && (xc - 1) >= (c) && (xr) < n &&
                           (xc - 1) < m && (r + 1) >= 0 && (c) >= 0
                       ? dp[r + 1][c][xr][xc - 1]
                       : 0) -
                  ((xr) >= (r + 1) && (xc) >= (c + 1) && (xr) < n && (xc) < m &&
                           (r + 1) >= 0 && (c + 1) >= 0
                       ? dp[r + 1][c + 1][xr][xc]
                       : 0) -
                  ((xr - 1) >= (r + 1) && (xc) >= (c) && (xr - 1) < n &&
                           (xc) < m && (r + 1) >= 0 && (c) >= 0
                       ? dp[r + 1][c][xr - 1][xc]
                       : 0) -
                  ((xr) >= (r) && (xc - 1) >= (c + 1) && (xr) < n &&
                           (xc - 1) < m && (r) >= 0 && (c + 1) >= 0
                       ? dp[r][c + 1][xr][xc - 1]
                       : 0) +
                  ((xr - 1) >= (r) && (xc - 1) >= (c + 1) && (xr - 1) < n &&
                           (xc - 1) < m && (r) >= 0 && (c + 1) >= 0
                       ? dp[r][c + 1][xr - 1][xc - 1]
                       : 0) +
                  ((xr - 1) >= (r + 1) && (xc - 1) >= (c) && (xr - 1) < n &&
                           (xc - 1) < m && (r + 1) >= 0 && (c) >= 0
                       ? dp[r + 1][c][xr - 1][xc - 1]
                       : 0) +
                  ((xr) >= (r + 1) && (xc - 1) >= (c + 1) && (xr) < n &&
                           (xc - 1) < m && (r + 1) >= 0 && (c + 1) >= 0
                       ? dp[r + 1][c + 1][xr][xc - 1]
                       : 0) +
                  ((xr - 1) >= (r + 1) && (xc) >= (c + 1) && (xr - 1) < n &&
                           (xc) < m && (r + 1) >= 0 && (c + 1) >= 0
                       ? dp[r + 1][c + 1][xr - 1][xc]
                       : 0) -
                  ((xr - 1) >= (r + 1) && (xc - 1) >= (c + 1) && (xr - 1) < n &&
                           (xc - 1) < m && (r + 1) >= 0 && (c + 1) >= 0
                       ? dp[r + 1][c + 1][xr - 1][xc - 1]
                       : 0);
            } else
              break;
        } else
          break;
    }
  for (int iq = 0; iq < (q); iq++) {
    int r1, r2, c1, c2;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    r1--;
    c1--;
    r2--;
    c2--;
    printf("%d\n", dp[r1][c1][r2][c2]);
  }
  return 0;
}
