#include <bits/stdc++.h>
char data[41][41];
int t[41][41][41][41];
int chk[41][41][41][41];
int main() {
  int a, b, c, d, i, j, k, l, p, q, sum = 0;
  scanf("%d %d %d", &a, &b, &q);
  for (i = 0; i < a; ++i) {
    scanf("%s", data[i]);
    for (j = 0; j < b; ++j) {
      if (data[i][j] == '0') {
        chk[i][j][i][j] = 1;
        for (k = i; k >= 0; --k) {
          for (l = j; l >= 0; --l) {
            if (l == j && k == i)
              t[k][l][i][j] = chk[k][l][i][j];
            else if (l == j) {
              chk[k][l][i][j] = ('1' - data[k][l]) && (chk[k + 1][l][i][j]);
              t[k][l][i][j] = t[k + 1][l][i][j] + chk[k][l][i][j];
            } else if (k == i) {
              chk[k][l][i][j] = ('1' - data[k][l]) && (chk[k][l + 1][i][j]);
              t[k][l][i][j] = t[k][l + 1][i][j] + chk[k][l][i][j];
            } else {
              chk[k][l][i][j] = ('1' - data[k][l]) && (chk[k + 1][l][i][j]) &&
                                (chk[k][l + 1][i][j]);
              t[k][l][i][j] = t[k + 1][l][i][j] + t[k][l + 1][i][j] -
                              t[k + 1][l + 1][i][j] + chk[k][l][i][j];
            }
          }
        }
      }
    }
  }
  for (p = 0; p < q; ++p) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    for (i = a - 1; i <= c - 1; ++i) {
      for (j = b - 1; j <= d - 1; ++j) {
        sum += t[a - 1][b - 1][i][j];
      }
    }
    printf("%d\n", sum);
    sum = 0;
  }
}
