#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int s[45][45];
int dp[45][45][45][45];
int row_sum[45][45];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &s[i][j]);
      if (s[i][j] == 1)
        row_sum[i][j] = 0;
      else
        row_sum[i][j] = row_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++) {
          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 width = d - b + 1;
          for (int i = c; i >= a; i--) {
            if (row_sum[i] == 0) break;
            width = min(width, row_sum[i][d]);
            dp[a][b][c][d] += width;
          }
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", dp[a][b][c][d]);
  }
  return 0;
}
