#include <bits/stdc++.h>
using namespace std;
int cnt[44][44][44][44];
int b[44][44];
int main() {
  int n, m, q;
  char buf[44];
  memset(b, 0, sizeof(b));
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%s", buf);
    for (int j = 0; j < m; ++j) {
      if (buf[j] == '1') {
        b[i + 1][j + 1] = 1;
      } else {
        b[i + 1][j + 1] = 0;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
    }
  }
  for (int ib = 1; ib <= n; ++ib) {
    for (int jb = 1; jb <= m; ++jb) {
      for (int ie = ib; ie <= n; ++ie) {
        for (int je = jb; je <= m; ++je) {
          cnt[ib][jb][ie][je] =
              (b[ie][je] - b[ib - 1][je] - b[ie][jb - 1] + b[ib - 1][jb - 1] ==
               0);
        }
      }
    }
  }
  for (int ib = n; ib > 1; --ib) {
    for (int jb = 1; jb <= m; ++jb) {
      for (int ie = ib; ie <= n; ++ie) {
        for (int je = jb; je <= m; ++je) {
          cnt[ib - 1][jb][ie][je] += cnt[ib][jb][ie][je];
        }
      }
    }
  }
  for (int ib = 1; ib <= n; ++ib) {
    for (int jb = m; jb > 1; --jb) {
      for (int ie = ib; ie <= n; ++ie) {
        for (int je = jb; je <= m; ++je) {
          cnt[ib][jb - 1][ie][je] += cnt[ib][jb][ie][je];
        }
      }
    }
  }
  for (int ib = 1; ib <= n; ++ib) {
    for (int jb = 1; jb <= m; ++jb) {
      for (int ie = ib; ie < n; ++ie) {
        for (int je = jb; je <= m; ++je) {
          cnt[ib][jb][ie + 1][je] += cnt[ib][jb][ie][je];
        }
      }
    }
  }
  for (int ib = 1; ib <= n; ++ib) {
    for (int jb = 1; jb <= m; ++jb) {
      for (int ie = ib; ie <= n; ++ie) {
        for (int je = jb; je < m; ++je) {
          cnt[ib][jb][ie][je + 1] += cnt[ib][jb][ie][je];
        }
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", cnt[a][b][c][d]);
  }
  return 0;
}
