#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[40][40];
int memo[40][40][40][40];
bool is_zero(int a, int b, int c, int d) {
  int s = A[c][d] - (b ? A[c][b - 1] : 0) - (a ? A[a - 1][d] : 0) +
          (a && b ? A[a - 1][b - 1] : 0);
  return s == 0;
}
int solve(int a, int b, int c, int d) {
  if (a > c || b > d) return 0;
  int &ans = memo[a][b][c][d];
  if (ans > -1) return ans;
  ans = 0;
  if (is_zero(a, b, c, d)) ans++;
  ans += solve(a, b, c - 1, d);
  ans += solve(a, b, c, d - 1);
  ans += solve(a + 1, b, c, d);
  ans += solve(a, b + 1, c, d);
  ans -= solve(a + 1, b, c - 1, d);
  ans -= solve(a, b + 1, c, d - 1);
  ans -= solve(a, b, c - 1, d - 1);
  ans -= solve(a + 1, b, c, d - 1);
  ans -= solve(a + 1, b + 1, c, d);
  ans -= solve(a, b + 1, c - 1, d);
  ans += solve(a, b + 1, c - 1, d - 1);
  ans += solve(a + 1, b, c - 1, d - 1);
  ans += solve(a + 1, b + 1, c, d - 1);
  ans += solve(a + 1, b + 1, c - 1, d);
  ans -= solve(a + 1, b + 1, c - 1, d - 1);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  memset((memo), (-1), sizeof(memo));
  int Q;
  cin >> N >> M >> Q;
  for (int _n(N), i(0); i < _n; i++)
    for (int _n(M), j(0); j < _n; j++) {
      char c;
      cin >> c;
      A[i][j] = c - '0';
    }
  for (int _n(N), i(0); i < _n; i++)
    for (int _n(M), j(0); j < _n; j++) {
      A[i][j] += (i ? A[i - 1][j] : 0) + (j ? A[i][j - 1] : 0) -
                 (i && j ? A[i - 1][j - 1] : 0);
    }
  for (int _n(Q), q(0); q < _n; q++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = solve(a - 1, b - 1, c - 1, d - 1);
    cout << ans << endl;
  }
  return 0;
}
