#include <bits/stdc++.h>
using namespace std;
int a[45][45], e[45][45][45][45], fw[45][45][45][45], n, m;
void update(int a, int b, int c, int d) {
  for (int i = a; i >= 1; i -= i & -i)
    for (int j = b; j >= 1; j -= j & -j)
      for (int k = c; k <= n; k += k & -k)
        for (int l = d; l <= m; l += l & -l) ++fw[i][j][k][l];
}
int sum(int a, int b, int c, int d) {
  int res = 0;
  for (int i = a; i <= n; i += i & -i)
    for (int j = b; j <= m; j += j & -j)
      for (int k = c; k >= 1; k -= k & -k)
        for (int l = d; l >= 1; l -= l & -l) res += fw[i][j][k][l];
  return res;
}
int main() {
  int 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]);
  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) {
          e[r1][c1][r2][c2] = !a[r2][c2];
          if (r2 > r1) e[r1][c1][r2][c2] &= e[r1][c1][r2 - 1][c2];
          if (c2 > c1) e[r1][c1][r2][c2] &= e[r1][c1][r2][c2 - 1];
          if (e[r1][c1][r2][c2]) update(r1, c1, r2, c2);
        }
  int a, b, c, d;
  while (q--) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", sum(a, b, c, d));
  }
}
