#include <bits/stdc++.h>
using namespace std;
int prc[46][46][46][46];
int dp[46][46][46][46];
bool viz[46][46][46][46];
int n, m, nrq, V[46], i, j, t;
int a[46][46], sp[46][46];
string s;
int memo(int x1, int y1, int x2, int y2) {
  if (viz[x1][y1][x2][y2] == true) return dp[x1][y1][x2][y2];
  viz[x1][y1][x2][y2] = true;
  int vald = prc[y1][y2][x2][x1];
  if (y1 == y2) return (dp[x1][y1][x2][y2] = vald);
  if (y2 - y1 == 1)
    return (dp[x1][y1][x2][y2] =
                memo(x1, y1, x2, y1) + memo(x1, y2, x2, y2) + vald);
  return (dp[x1][y1][x2][y2] = memo(x1, y1, x2, y2 - 1) +
                               memo(x1, y1 + 1, x2, y2) -
                               memo(x1, y1 + 1, x2, y2 - 1) + vald);
}
int main() {
  cin >> n >> m >> nrq;
  cin.get();
  for (i = 1; i <= n; ++i) {
    cin >> s;
    for (j = 0; j < m; ++j) {
      a[i][j + 1] = s[j] - '0';
      sp[i][j + 1] = sp[i][j] + a[i][j + 1];
    }
  }
  for (i = 1; i <= m; ++i)
    for (j = 1; j <= m; ++j) {
      int nrl = 0;
      for (t = 1; t <= n; ++t)
        if (sp[t][j] - sp[t][i - 1] == 0)
          V[t] = 0;
        else
          V[t] = 1;
      for (t = 1, nrl = 0; t <= n; ++t) {
        if (V[t] == 1)
          nrl = 0;
        else
          ++nrl;
        for (int e = t; e > 0; --e) {
          int rg = min(nrl, (t - e + 1));
          prc[i][j][t][e] = prc[i][j][t - 1][e] + rg;
        }
      }
    }
  for (i = 1; i <= nrq; ++i) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << memo(x1, y1, x2, y2) << '\n';
  }
  return 0;
}
