#include <bits/stdc++.h>
using namespace std;
int dp[45][45][45][45], str[45][45], row[45][45];
int main() {
  int N, M, Q, a, b, c, d, e, r;
  scanf("%d%d%d", &N, &M, &Q);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) {
      scanf("%1d", &str[i][j]);
      row[i][j] = row[i][j - 1];
      if (str[i][j])
        row[i][j] = 0;
      else
        row[i][j]++;
    }
  for (a = 1; a <= N; a++) {
    for (b = 1; b <= M; b++) {
      for (c = a; c <= N; c++) {
        for (d = b; d <= M; d++) {
          dp[a][b][c][d] =
              dp[a][b][c - 1][d] + dp[a][b][c][d - 1] - dp[a][b][c - 1][d - 1];
          r = d - b + 1;
          for (e = c; e >= a && r; e--) {
            r = (r < row[e][d]) ? r : row[e][d];
            dp[a][b][c][d] += r;
          }
        }
      }
    }
  }
  while (Q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", dp[a][b][c][d]);
  }
  return 0;
}
