#include <bits/stdc++.h>
using namespace std;
const int maxn = 40 + 2;
int n, m, q, dp[maxn][maxn][maxn][maxn], ones[maxn][maxn], a, b, c, d;
int main() {
  ios::sync_with_stdio(false);
  char ch;
  cin >> n >> m >> q;
  for (int _b = (n), i = (1); i <= _b; ++i)
    for (int _b = (m), j = (1); j <= _b; ++j) {
      cin >> ch;
      ones[i][j] =
          ones[i - 1][j] + ones[i][j - 1] - ones[i - 1][j - 1] + ch - '0';
    }
  for (int _b = (n - 1), h = (0); h <= _b; ++h)
    for (int _b = (m - 1), w = (0); w <= _b; ++w)
      for (int _b = (n - h), i = (1); i <= _b; ++i)
        for (int _b = (m - w), j = (1); j <= _b; ++j) {
          a = i, b = j, c = i + h, d = j + w;
          dp[a][b][c][d] = ((ones[c][d] - ones[a - 1][d] - ones[c][b - 1] +
                             ones[a - 1][b - 1]) == 0);
          for (int _b = ((1 << 4) - 1), mask = (1); mask <= _b; ++mask) {
            dp[a][b][c][d] += (-1 + 2 * (__builtin_popcount(mask) & 1)) *
                              dp[a + (mask >> 0 & 1)][b + (mask >> 1 & 1)]
                                [c - (mask >> 2 & 1)][d - (mask >> 3 & 1)];
          }
        }
  while (q--) {
    cin >> a >> b >> c >> d;
    cout << dp[a][b][c][d] << endl;
  }
  return 0;
}
