#include <bits/stdc++.h>
using namespace std;
const int maxn = 40 + 5;
int n, m, q, qa, qb, qc, qd, dp[maxn][maxn], sol[maxn][maxn][maxn][maxn];
char M[maxn][maxn];
vector<int> V[maxn][maxn][maxn];
bool good(int a, int b, int c, int d) {
  int ret = dp[c][d] - dp[a - 1][d] - dp[c][b - 1] + dp[a - 1][b - 1];
  return (ret == 0);
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%s", M[i] + 1);
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      dp[a][b] =
          dp[a - 1][b] + dp[a][b - 1] - dp[a - 1][b - 1] + (M[a][b] == '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++)
          if (good(a, b, c, d)) V[b][c][d].push_back(a);
  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++) {
          if (c > a) sol[a][b][c][d] += sol[a][b][c - 1][d];
          if (d > b) sol[a][b][c][d] += sol[a][b][c][d - 1];
          if (c > a && d > b) sol[a][b][c][d] -= sol[a][b][c - 1][d - 1];
          for (int curr_b = d; curr_b >= b; curr_b--)
            if (V[curr_b][c][d].size()) {
              vector<int>::iterator it = lower_bound(V[curr_b][c][d].begin(),
                                                     V[curr_b][c][d].end(), a);
              sol[a][b][c][d] += (int)(V[curr_b][c][d].end() - it);
            }
        }
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d %d", &qa, &qb, &qc, &qd);
    printf("%d\n", sol[qa][qb][qc][qd]);
  }
  return 0;
}
