#include <bits/stdc++.h>
using namespace std;
char in[64][64];
int s[44][44][44][44];
int h[44][44], n, m, qu;
map<int, int> temp;
int main() {
  scanf("%d%d%d ", &n, &m, &qu);
  for (int i = 1; i <= n; ++i) gets(in[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      h[i][j] = (in[i][j] == '1') + h[i - 1][j] + h[i][j - 1] - h[i - 1][j - 1];
  for (int a = 1; a <= n; ++a)
    for (int b = 1; b <= m; ++b)
      for (int i = a; i <= n; ++i)
        for (int j = b; j <= m; ++j)
          s[a][b][i][j] =
              s[a][b][i - 1][j] + s[a][b][i][j - 1] - s[a][b][i - 1][j - 1] +
              (h[i][j] + h[i - a][j - b] - h[i - a][j] - h[i][j - b] == 0);
  for (int a, b, c, d; qu--;) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans = 0;
    int key = a << 24 | b << 16 | c << 8 | d;
    if (temp.count(key))
      ans = temp[key];
    else
      for (int p = c - a + 1, i = c - 1; p >= 1; --p, --i)
        for (int q = d - b + 1, j = d - 1; q >= 1; --q, --j) {
          ans += s[p][q][c][d] + s[p][q][i][j] - s[p][q][c][j] - s[p][q][i][d];
        }
    temp[key] = ans;
    printf("%d\n", ans);
  }
}
