#include <bits/stdc++.h>
const int N = 42;
int dp[N][N][N][N];
char g[N][N];
int top[N][N];
int main() {
  int n, m, q, i, j;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) {
    scanf("%s", g[i] + 1);
    for (j = 1; j <= m; j++)
      if (g[i][j] == '0')
        top[i][j] = top[i - 1][j] + 1;
      else
        top[i][j] = 0;
  }
  int a, b, c, d;
  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];
          int minH = ((top[c][d]) < (c - a + 1) ? (top[c][d]) : (c - a + 1));
          for (i = d; i >= b; i--) {
            minH = ((top[c][i]) < (minH) ? (top[c][i]) : (minH));
            if (minH == 0)
              break;
            else
              dp[a][b][c][d] += minH;
          }
        }
  while (q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", dp[a][b][c][d]);
  }
  return 0;
}
