#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 40 + 10;
int n, m, q, a[N][N];
unsigned long long dp[N][N][N][N];
int p[N][N][N];
inline void input() {
  cin >> n >> m >> q;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) a[i][j + 1] = s[j] - '0';
  }
}
inline void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (!a[i][j]) {
        dp[i][i][j][j] = 1;
        p[i][j][j] = j - 1;
      } else
        p[i][j][j] = j;
    }
  for (int k = 1; k < m; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (j + k > m) break;
        if (!a[i][j + k]) {
          p[i][j][j + k] = p[i][j][j + k - 1];
          dp[i][i][j][j + k] =
              dp[i][i][j][j + k - 1] + (j + k - p[i][j][j + k]);
        } else {
          p[i][j][j + k] = j + k;
          dp[i][i][j][j + k] = dp[i][i][j][j + k - 1];
        }
      }
  int mn;
  for (int k = 1; k < n; k++)
    for (int l = 0; l < m; l++)
      for (int i = 1; i <= n; i++) {
        if (i + k > n) break;
        for (int j = 1; j <= m; j++) {
          if (j + l > m) break;
          dp[i][i + k][j][j + l] = dp[i][i + k - 1][j][j + l] +
                                   dp[i][i + k][j][j + l - 1] -
                                   dp[i][i + k - 1][j][j + l - 1];
          if (a[i + k][j + l]) continue;
          for (int d = i + k; d >= i + k; d--) {
            mn = p[d][j][j + l];
            dp[i][i + k][j][j + l] += j + l - mn;
            for (int c = d - 1; c >= i; c--) {
              mn = max(mn, p[c][j][j + l]);
              if (mn == j + l) break;
              dp[i][i + k][j][j + l] += j + l - mn;
            }
          }
        }
      }
}
int main() {
  ios_base::sync_with_stdio(0);
  input();
  solve();
  int x1, x2, y1, y2;
  for (int i = 0; i < q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << dp[x1][x2][y1][y2] << endl;
  }
  return 0;
}
