#include <bits/stdc++.h>
using namespace std;
long long mas[41][41];
long long dp[45][45][45][45];
void Solve() {
  int n, m, q, t, b, l, r;
  scanf("%d %d %d", &n, &m, &q);
  char buf[50];
  for (t = 1; t <= n; t++) {
    scanf("%s", buf);
    for (l = 1; l <= m; l++) {
      mas[t][l] =
          mas[t - 1][l] + mas[t][l - 1] - mas[t - 1][l - 1] + buf[l - 1] - '0';
    }
  }
  for (t = n; t > 0; t--) {
    for (l = m; l > 0; l--) {
      for (b = t; b <= n; b++) {
        for (r = l; r <= m; r++) {
          long long &v = dp[t][l][b][r];
          v = (mas[b][r] - mas[t - 1][r] - mas[b][l - 1] + mas[t - 1][l - 1]) ==
              0;
          v += dp[t + 1][l][b][r] + dp[t][l + 1][b][r] + dp[t][l][b][r - 1] +
               dp[t][l][b - 1][r] - dp[t + 1][l + 1][b][r] -
               dp[t + 1][l][b][r - 1] - dp[t + 1][l][b - 1][r] -
               dp[t][l + 1][b][r - 1] - dp[t][l + 1][b - 1][r] -
               dp[t][l][b - 1][r - 1] + dp[t + 1][l + 1][b][r - 1] +
               dp[t + 1][l + 1][b - 1][r] + dp[t + 1][l][b - 1][r - 1] +
               dp[t][l + 1][b - 1][r - 1] - dp[t + 1][l + 1][b - 1][r - 1];
        }
      }
    }
  }
  while (q--) {
    scanf("%d %d %d %d", &t, &l, &b, &r);
    printf("%I64d\n", dp[t][l][b][r]);
  }
}
int main() {
  Solve();
  return 0;
}
