#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() {
    cin.sync_with_stdio(0);
    cin.tie(0);
  }
} _;
const int N = 50;
int cnt[N][N], dp[2][N][N][N][N];
int yes(int a, int b, int c, int d) {
  int num = cnt[c][d] - cnt[a - 1][d] - cnt[c][b - 1] + cnt[a - 1][b - 1];
  return (num == (c - a + 1) * (d - b + 1));
}
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; ++j)
      cnt[i][j] =
          (s[j - 1] == '0') + cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1];
  }
  for (int a = n; a >= 1; --a)
    for (int b = m; b >= 1; --b)
      for (int c = a; c <= n; ++c)
        for (int d = b; d <= m; ++d)
          dp[0][a][b][c][d] = yes(a, b, c, d) + dp[0][a][b][c - 1][d] +
                              dp[0][a][b][c][d - 1] - dp[0][a][b][c - 1][d - 1];
  for (int c = 1; c <= n; ++c)
    for (int d = 1; d <= m; ++d)
      for (int a = 1; a <= c; ++a)
        for (int b = 1; b <= d; ++b)
          dp[1][a][b][c][d] = dp[0][a][b][c][d] + dp[1][a - 1][b][c][d] +
                              dp[1][a][b - 1][c][d] - dp[1][a - 1][b - 1][c][d];
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ret = dp[1][c][d][c][d] - dp[1][a - 1][d][c][d] -
              dp[1][c][b - 1][c][d] + dp[1][a - 1][b - 1][c][d];
    cout << ret << '\n';
  }
  return 0;
}
