#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > v;
vector<vector<vector<vector<long long> > > > dp(
    44, vector<vector<vector<long long> > >(
            44, vector<vector<long long> >(44, vector<long long>(44, 0))));
vector<vector<long long> > dpleft(44, vector<long long>(44, 0));
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  v.resize(n, vector<char>(m, 0));
  getchar();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      c -= '0';
      v[i][j] = c;
    }
  }
  for (int r = 0; r < n; ++r) {
    for (int k = 0; k < m; ++k) {
      dpleft.assign(44, vector<long long>(44, 0));
      if (v[r][k] == 0) {
        dp[r][k][r][k] = 1;
        dpleft[r][k] = 1;
      }
      for (int j = k + 1; j < m; ++j) {
        if (v[r][j] == 0) {
          dp[r][k][r][j] = dp[r][k][r][j - 1] + dpleft[r][j - 1] + 1;
          dpleft[r][j] = dpleft[r][j - 1] + 1;
        } else
          dp[r][k][r][j] = dp[r][k][r][j - 1];
      }
      for (int i = r + 1; i < n; ++i) {
        for (int j = k; j < m; ++j) {
          dp[r][k][i][j] += dp[r][k][i - 1][j];
          if (j != k) {
            dp[r][k][i][j] += dp[r][k][i][j - 1];
            dp[r][k][i][j] -= dp[r][k][i - 1][j - 1];
          }
          if (v[i][j] == 0) {
            long long mn = 1e18;
            if (j != k)
              dpleft[i][j] = dpleft[i][j - 1] + 1;
            else
              dpleft[i][j] = 1;
            for (int l = i; l >= r; l--) {
              if (v[l][j] == 1) break;
              mn = min(mn, dpleft[l][j]);
              int cnt = mn;
              dp[r][k][i][j] += cnt;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    long long res = dp[a][b][c][d];
    cout << res << '\n';
  }
  return 0;
}
