#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40 + 5;
int n, m, q;
int grid[MAXN][MAXN];
int dp[MAXN][MAXN][MAXN][MAXN];
long long psa[MAXN][MAXN][MAXN][MAXN];
int howMany(int x1, int y1, int x2, int y2) {
  int h = y2 - y1 + 1;
  int w = x2 - x1 + 1;
  if (h == 0 || w == 0) return 0;
  if (dp[x1][y1][x2][y2] != -1) return dp[x1][y1][x2][y2];
  int count = howMany(x1, y1, x2 - 1, y2) + howMany(x1, y1, x2, y2 - 1) -
              howMany(x1, y1, x2 - 1, y2 - 1);
  if (count == h * w - 1 && grid[x2][y2] == 0) count++;
  return dp[x1][y1][x2][y2] = count;
}
long long rsq(int x1, int y1, int x2, int y2) { return psa[x2][y2][x1][y1]; }
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  char val;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> val, grid[i][j] = val - '0';
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k > 0; k--) {
        for (int l = j; l > 0; l--) {
          psa[i][j][k][l] = psa[i][j][k + 1][l] + psa[i][j][k][l + 1] -
                            psa[i][j][k + 1][l + 1] + howMany(k, l, i, j);
        }
      }
    }
  }
  int x1, y1, x2, y2;
  while (q--) {
    cin >> x1 >> y1 >> x2 >> y2;
    long long ans = 0;
    ans = rsq(x1, y1, x2, y2);
    cout << ans << "\n";
  }
}
