#include <bits/stdc++.h>
using namespace std;
int ans[45][45][45][45], a[45][45], b[45][45];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      scanf("%1d", &a[i][j]);
      if (a[i][j])
        b[i][j] = 0;
      else
        b[i][j] = b[i][j - 1] + 1;
    }
  for (int r1 = 1; r1 <= n; ++r1)
    for (int c1 = 1; c1 <= m; ++c1)
      for (int r2 = r1; r2 <= n; ++r2)
        for (int c2 = c1; c2 <= m; ++c2) {
          if (r2 > r1) ans[r1][c1][r2][c2] += ans[r1][c1][r2 - 1][c2];
          if (c2 > c1) ans[r1][c1][r2][c2] += ans[r1][c1][r2][c2 - 1];
          if (r2 > r1 && c2 > c1)
            ans[r1][c1][r2][c2] -= ans[r1][c1][r2 - 1][c2 - 1];
          int w = c2 - c1 + 1;
          for (int i = r2; i >= r1; --i) {
            w = min(w, b[i][c2]);
            ans[r1][c1][r2][c2] += w;
          }
        }
  int a, b, c, d;
  while (q--) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", ans[a][b][c][d]);
  }
}
