#include <bits/stdc++.h>
using namespace std;
int n, m, j, k, i, l, x;
int dp[45][45];
int Stack[10000][3];
int indis;
int s, beg, y, q, x1, x2, sadfas, y2;
char A[45][45];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf(" %c", &A[i][j]);
  int qwe;
  for (qwe = 1; qwe <= q; qwe++) {
    scanf("%d %d %d %d", &x1, &sadfas, &x2, &y2);
    for (i = x1; i <= x2; i++) dp[sadfas - 1][i] = 0;
    for (i = sadfas; i <= y2; i++)
      for (j = x1; j <= x2; j++) {
        if (A[j][i] == '0')
          dp[i][j] = dp[i - 1][j] + 1;
        else
          dp[i][j] = 0;
      }
    for (i = sadfas; i <= y2; i++) {
      dp[i][x2 + 1] = 0;
      for (j = x1; j <= x2 + 1; j++) {
        beg = j;
        while (indis && Stack[indis][1] >= dp[i][j]) {
          x = Stack[indis][1];
          beg = Stack[indis][2];
          indis--;
          if (!indis) {
            l = dp[i][j];
            s += (x - l) * (j - beg + 1) * (j - beg) / 2;
            break;
          }
          l = max(Stack[indis][1], dp[i][j]);
          s += (x - l) * (j - beg + 1) * (j - beg) / 2;
        }
        indis++;
        Stack[indis][1] = dp[i][j];
        Stack[indis][2] = beg;
      }
    }
    printf("%d\n", s);
    s = 0;
  }
  return 0;
}
