#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, d, tmp, q, A[41][41][41][41], ps[41][41];
char Q[42][42];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", Q[i] + 1);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (Q[i][j] == '0') ps[i][j] = ps[i][j - 1] + 1;
    }
  }
  for (a = 1; a <= n; a++) {
    for (b = 1; b <= m; b++) {
      for (c = a; c <= n; c++) {
        for (d = b; d <= m; d++) {
          A[a][b][c][d] =
              A[a][b][c - 1][d] + A[a][b][c][d - 1] - A[a][b][c - 1][d - 1];
          tmp = d - b + 1;
          for (int i = c; i >= a; i--) {
            if (ps[i][d] < tmp) tmp = ps[i][d];
            A[a][b][c][d] += tmp;
          }
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", A[a][b][c][d]);
  }
}
