#include <bits/stdc++.h>
using namespace std;
const int MAXN = 45;
int n, m, q;
int sum[MAXN][MAXN], f[MAXN][MAXN][MAXN][MAXN];
int get_sum(int i, int j, int ii, int jj) {
  return sum[ii][jj] - sum[i - 1][jj] - sum[ii][j - 1] + sum[i - 1][j - 1];
}
void calcF(int f[MAXN][MAXN]) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + f[i][j];
}
int ans[MAXN][MAXN][MAXN][MAXN];
int t[MAXN][MAXN];
string s[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) sum[i][j] = s[i - 1][j - 1] - '0';
  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] + sum[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int ii = i; ii <= n; ii++)
        for (int jj = j; jj <= m; jj++) {
          int x = get_sum(i, j, ii, jj);
          if (x == 0) f[i][j][ii][jj]++;
        }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) calcF(f[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      memset(t, 0, sizeof(t));
      for (int ii = n; ii > 0; ii--)
        for (int jj = m; jj > 0; jj--) {
          t[ii][jj] = t[ii + 1][jj] + t[ii][jj + 1] - t[ii + 1][jj + 1] +
                      f[ii][jj][i][j];
          ans[ii][jj][i][j] = t[ii][jj];
        }
    }
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ans[a][b][c][d] << '\n';
  }
  return 0;
}
