#include <bits/stdc++.h>
using namespace std;
int n, m, t;
int maps[60][60] = {0};
long long f[60][60][60][60] = {0};
int p[60][60] = {0};
void dp() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = i; k <= n; k++)
        for (int q = j; q <= m; q++) {
          f[i][j][k][q] =
              f[i][j][k][q - 1] + f[i][j][k - 1][q] - f[i][j][k - 1][q - 1];
          long long w = min(p[k][q], q - j + 1);
          f[i][j][k][q] += w;
          for (int pp = k - 1; pp >= i; pp--) {
            if (w == 0) break;
            w = min(w, (long long)min(p[pp][q], q - j + 1));
            f[i][j][k][q] += w;
          }
        }
}
int main() {
  cin >> n >> m >> t;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%1d", &maps[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = j; k >= 1 && maps[i][k] == 0; k--) p[i][j]++;
    }
  }
  dp();
  for (int it = 1; it <= t; it++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    cout << f[a][b][c][d] << endl;
  }
  return 0;
}
