#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n, m, q;
int A[40 + 1 + 9][40 + 1 + 9];
int a, b, c, d;
int memo[40 + 1 + 9][40 + 1 + 9][40 + 1 + 9][40 + 1 + 9];
int sum[40 + 1 + 9][40 + 1 + 9];
int dp[40 + 1 + 9][40 + 1 + 9][40 + 1 + 9][40 + 1 + 9];
void build_sum() {
  memset(sum, 0, sizeof sum);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + A[i][j];
    }
  }
}
int sum_q(int a, int b, int c, int d) {
  if (a <= 0 || b <= 0) return 1;
  return sum[c][d] - sum[a - 1][d] - sum[c][b - 1] + sum[a - 1][b - 1];
}
void build_dp() {
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 1; k <= n; k++) {
        for (int l = 1; l <= m; l++) {
          int &ret = dp[i][j][k][l];
          ret +=
              dp[i - 1][j][k][l] + dp[i][j - 1][k][l] - dp[i - 1][j - 1][k][l];
          if (sum_q(i - k + 1, j - l + 1, i, j) == 0) ret++;
        }
      }
    }
  }
}
int query(int a, int b, int c, int d) {
  int &ret = memo[a][b][c][d];
  if (ret != -1) return ret;
  ret = 0;
  for (int k = 1; k <= c - a + 1; k++) {
    bool yet = 0;
    for (int l = 1; l <= d - b + 1; l++) {
      int nw = dp[c][d][k][l] - dp[a + k - 1 - 1][d][k][l] -
               dp[c][b + l - 1 - 1][k][l] +
               dp[a + k - 1 - 1][b + l - 1 - 1][k][l];
      ret += nw;
      if (nw != 0) yet = 1;
      if (nw == 0) break;
    }
    if (!yet) break;
  }
  return ret;
}
int main() {
  read_file();
  while (scanf("%d%d%d", &n, &m, &q) != EOF) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%1d", &A[i][j]);
    build_sum();
    build_dp();
    memset(memo, -1, sizeof memo);
    while (q--) {
      int a, b, c, d;
      scanf("%d%d%d%d", &a, &b, &c, &d);
      int ans = query(a, b, c, d);
      printf("%d\n", ans);
    }
  }
}
