#include <bits/stdc++.h>
char g[42][42];
int sum[41][41] = {0}, dp[41][41][41][41] = {0};
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (g[i][j] == '0') sum[i][j] = sum[i][j - 1] + 1;
    }
  }
  for (int a = 1; a <= n; ++a)
    for (int b = 1; b <= m; ++b)
      for (int c = a; c <= n; ++c)
        for (int d = b; d <= m; ++d) {
          int l = d - b + 1;
          dp[a][b][c][d] =
              dp[a][b][c - 1][d] + dp[a][b][c][d - 1] - dp[a][b][c - 1][d - 1];
          for (int i = c; i >= a; --i) {
            if (sum[i][d] < l) l = sum[i][d];
            dp[a][b][c][d] += l;
          }
        }
  int a, b, x, y;
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d%d", &a, &b, &x, &y);
    printf("%d\n", dp[a][b][x][y]);
  }
  return 0;
}
