#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int d[41][41][41][41], h[41][41];
char m[41][41];
int main() {
  int r, c, i, j, k, l, t, f, v, q;
  for (scanf("%d%d%d", &r, &c, &q), i = 0; i < r; i++)
    for (scanf("%s", m[i]), j = 0; j < c; m[i][j] -= '0', j++)
      ;
  for (i = 0; i < r; i++)
    for (j = i; j < r; j++)
      for (t = 0; t < c; t++) {
        for (k = i; k <= j; k++)
          for (l = k; l <= j; h[k][l] = 0, l++)
            ;
        v = 0;
        for (f = t; f < c; f++) {
          for (k = i; k <= j; k++) {
            for (l = k; l <= j && !m[l][f]; l++) {
              h[k][l]++;
              v += h[k][l];
            }
            for (; l <= j; h[k][l] = 0, l++)
              ;
          }
          d[i][j][t][f] = v;
        }
      }
  for (; q--; scanf("%d%d%d%d", &i, &j, &k, &l),
              printf("%d\n", d[i - 1][k - 1][j - 1][l - 1]))
    ;
  return 0;
}
