#include <bits/stdc++.h>
using namespace std;
int row[41][41], a[41][41], dp[41][41][41][41];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
      row[i][j] = row[i][j - 1];
      if (a[i][j])
        row[i][j] = 0;
      else
        row[i][j]++;
    }
  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][d - 1] + dp[a][b][c - 1][d] - dp[a][b][c - 1][d - 1];
          int r = d - b + 1;
          for (int e = c; e >= a; e--) {
            r = min(r, row[e][d]);
            dp[a][b][c][d] += r;
          }
        }
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    cout << dp[a][b][c][d] << endl;
  }
  return 0;
}
