#include <bits/stdc++.h>
struct T {
  int up, left, c;
} dp[45][45][45][45];
int n, m, q, cnt[45][45][45][45];
char a[45][45];
void solve(int lx, int ly) {
  for (int i = 0; i < 45; ++i)
    for (int j = 0; j < 45; ++j)
      dp[lx][ly][i][j].up = dp[lx][ly][i][j].left = dp[lx][ly][i][j].c = 0;
  if (a[lx][ly] == '0') dp[lx][ly][lx][ly].up = dp[lx][ly][lx][ly].left = 1;
  for (int i = lx + 1; i <= n; ++i)
    if (a[i][ly] == '0') {
      dp[lx][ly][i][ly].up = dp[lx][ly][i - 1][ly].up + 1;
      dp[lx][ly][i][ly].left = 1;
    }
  for (int i = ly + 1; i <= m; ++i)
    if (a[lx][i] == '0') {
      dp[lx][ly][lx][i].up = 1;
      dp[lx][ly][lx][i].left = dp[lx][ly][lx][i - 1].left + 1;
    }
  for (int i = lx + 1; i <= n; ++i)
    for (int j = ly + 1; j <= m; ++j)
      if (a[i][j] == '0') {
        dp[lx][ly][i][j].up = dp[lx][ly][i - 1][j].up + 1;
        dp[lx][ly][i][j].left = dp[lx][ly][i][j - 1].left + 1;
      }
  for (int j = ly; j <= m; ++j)
    for (int i = lx; i <= n; ++i)
      if (a[i][j] == '0') {
        if (i == lx && j == ly)
          dp[lx][ly][i][j].c = 1;
        else if (i == lx)
          dp[lx][ly][i][j].c = dp[lx][ly][i][j - 1].c + 1;
        else if (j == ly)
          dp[lx][ly][i][j].c = dp[lx][ly][i - 1][j].c + 1;
        else {
          if (dp[lx][ly][i][j].left >= dp[lx][ly][i - 1][j].left)
            dp[lx][ly][i][j].c = dp[lx][ly][i - 1][j].c + dp[lx][ly][i][j].left;
          else {
            int h = i - 1;
            while (h >= lx && dp[lx][ly][h][j].left > dp[lx][ly][i][j].left)
              --h;
            if (h == lx - 1)
              dp[lx][ly][i][j].c = (i - h) * dp[lx][ly][i][j].left;
            else
              dp[lx][ly][i][j].c =
                  dp[lx][ly][h][j].c + (i - h) * dp[lx][ly][i][j].left;
          }
        }
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf(" %c", &a[i][j]);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) solve(i, j);
  for (int id = 1; id <= q; ++id) {
    int b, c, d, e;
    scanf("%d%d%d%d", &b, &c, &d, &e);
    int ans = 0;
    for (int i = b; i <= d; ++i)
      for (int j = c; j <= e; ++j) ans += dp[b][c][i][j].c;
    printf("%d\n", ans);
  }
  return 0;
}
