#include <bits/stdc++.h>
using namespace std;
int n, m, Q, l, r, d, u;
char s[42][42];
int sum[42][42], dp[42][42][42][42];
void init() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) sum[i][j] = sum[i][j - 1] + s[i][j] - '0';
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) sum[i][j] += sum[i - 1][j];
  for (int len1 = 1; len1 <= n; len1++) {
    for (int l = 1; l + len1 - 1 <= n; l++) {
      int r = l + len1 - 1;
      for (int len2 = 1; len2 <= m; len2++) {
        for (int d = 1; d + len2 - 1 <= m; d++) {
          int u = d + len2 - 1;
          dp[l][r][d][u] =
              dp[l][r - 1][d][u] + dp[l][r][d][u - 1] - dp[l][r - 1][d][u - 1];
          int h2 = u + 1;
          for (int h = l; h <= r; h++) {
            while (h2 > d && sum[r][u] + sum[h - 1][h2 - 1 - 1] -
                                     sum[h - 1][u] - sum[r][h2 - 1 - 1] ==
                                 0)
              h2--;
            dp[l][r][d][u] += u - h2 + 1;
          }
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  init();
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d%d%d", &l, &d, &r, &u);
    printf("%d\n", dp[l][r][d][u]);
  }
  return 0;
}
