#include <bits/stdc++.h>
using namespace std;
int n, m, q, i, j, p1, p2, p3, p4, sum, Min, a[41][41], d[41][41],
    f[41][41][41][41], g[41][41][41][41];
char ch;
int main() {
  scanf("%d%d%d\n", &n, &m, &q);
  for (i = 1; i <= n; i++, scanf("\n"))
    for (j = 1; j <= m; j++) {
      ch = getchar();
      a[i][j] = ch - '0';
    }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (!a[i][j]) d[i][j] = d[i - 1][j] + 1;
  for (i = 1; i <= n; i++)
    for (p1 = n; p1 >= i; p1--)
      for (p2 = m; p2; p2--) {
        sum = 0;
        Min = 1e9;
        for (j = p2; j; j--) {
          Min = min(Min, d[p1][j]);
          sum += min(p1 - i + 1, Min);
          g[i][j][p1][p2] = sum;
        }
      }
  for (p1 = 1; p1 <= n; p1++)
    for (p2 = 1; p2 <= m; p2++)
      for (p3 = p1; p3 <= n; p3++)
        for (p4 = p2; p4 <= m; p4++) {
          if (p3 != p1) f[p1][p2][p3][p4] += f[p1][p2][p3 - 1][p4];
          if (p4 != p2) f[p1][p2][p3][p4] += f[p1][p2][p3][p4 - 1];
          if (p3 != p1 && p4 != p2)
            f[p1][p2][p3][p4] -= f[p1][p2][p3 - 1][p4 - 1];
          f[p1][p2][p3][p4] += g[p1][p2][p3][p4];
        }
  for (; q; q--) {
    scanf("%d%d%d%d\n", &p1, &p2, &p3, &p4);
    printf("%d\n", f[p1][p2][p3][p4]);
  }
}
