#include <bits/stdc++.h>
using namespace std;
const int N = 45;
int n, m, q, mat[N][N], dp[N][N][N][N];
char arr[N][N];
bool query(int a, int b, int c, int d) {
  int res = mat[c][d];
  if (a) res -= mat[a - 1][d];
  if (b) res -= mat[c][b - 1];
  if (a && b) res += mat[a - 1][b - 1];
  return !res;
}
void init() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> arr[i][j];
  for (int i = 0; i < m; ++i) mat[0][i] = arr[0][i] - '0';
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < m; ++j) mat[i][j] = (arr[i][j] - '0') + mat[i - 1][j];
  for (int i = 0; i < n; ++i)
    for (int j = 1; j < m; ++j) mat[i][j] += mat[i][j - 1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  for (int a = n - 1; a >= 0; --a) {
    for (int b = m - 1; b >= 0; --b) {
      for (int c = 0; c < n; ++c) {
        for (int d = 0; d < m; ++d) {
          int &ret = dp[a][b][c][d];
          if (a > c || b > d) {
            ret = 0;
            continue;
          }
          ret = query(a, b, c, d);
          ret += dp[a + 1][b][c][d] + dp[a][b + 1][c][d] + dp[a][b][c - 1][d] +
                 dp[a][b][c][d - 1];
          ret = ret - dp[a + 1][b + 1][c][d] - dp[a + 1][b][c - 1][d] -
                dp[a + 1][b][c][d - 1] - dp[a][b + 1][c - 1][d] -
                dp[a][b + 1][c][d - 1] - dp[a][b][c - 1][d - 1];
          ret += dp[a + 1][b + 1][c - 1][d] + dp[a + 1][b + 1][c][d - 1] +
                 dp[a + 1][b][c - 1][d - 1] + dp[a][b + 1][c - 1][d - 1];
          ret -= dp[a + 1][b + 1][c - 1][d - 1];
        }
      }
    }
  }
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c, --d;
    cout << dp[a][b][c][d] << '\n';
  }
  return 0;
}
