#include <bits/stdc++.h>
using namespace std;
int dp[45][45][45][45], bara[45][45], n, m;
char grid[45][45];
void setup(void) {
  int i, j, k, p, q, x, y, x1, y1, x2, y2;
  for (x1 = 1; x1 <= n; x1++) {
    for (y1 = 1; y1 <= m; y1++) {
      for (x2 = x1; x2 <= n; x2++) {
        for (y2 = y1; y2 <= m; y2++) {
          dp[x1][y1][x2][y2] = dp[x1][y1][x2 - 1][y2] + dp[x1][y1][x2][y2 - 1] -
                               dp[x1][y1][x2 - 1][y2 - 1];
          p = min(bara[x2][y2], y2 - y1 + 1);
          for (i = x2; i >= x1; i--) {
            dp[x1][y1][x2][y2] += p;
            p = min(p, bara[i - 1][y2]);
          }
        }
      }
    }
  }
  return;
}
int main() {
  int i, j, k, p, q, x, y, x1, y1, x2, y2;
  cin >> n >> m >> q;
  for (i = 1; i <= n; i++) scanf("%s", grid[i] + 1);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      bara[i][j] = (bara[i][j - 1] * (grid[i][j] == '0')) + (grid[i][j] == '0');
  }
  setup();
  while (q--) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << dp[x1][y1][x2][y2] << endl;
  }
  return 0;
}
