#include <bits/stdc++.h>
using namespace std;
const int MaxN = 41;
char a[MaxN][MaxN];
int sum[MaxN][MaxN];
int hCur[MaxN][MaxN][MaxN][MaxN];
int sumSq[MaxN][MaxN][MaxN][MaxN];
bool isSumZero(int r1, int c1, int r2, int c2) {
  return (sum[r2][c2] - sum[r2][c1 - 1] - sum[r1 - 1][c2] +
          sum[r1 - 1][c1 - 1]) == 0;
}
int main() {
  int n, m, q;
  scanf("%d%d%d\n", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      sum[i][j] =
          (a[i][j] - '0') + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
  for (int lenRow = 1; lenRow <= n; lenRow++)
    for (int lenCol = 1; lenCol <= m; lenCol++)
      for (int i = 1; i <= n - lenRow + 1; i++)
        for (int j = 1; j <= m - lenCol + 1; j++) {
          int i1 = i + lenRow - 1, j1 = j + lenCol - 1;
          hCur[i][j][i1][j1] = isSumZero(i, j, i1, j1) +
                               hCur[i][j][i1 - 1][j1] + hCur[i][j][i1][j1 - 1] -
                               hCur[i][j][i1 - 1][j1 - 1];
        }
  for (int lenRow = 1; lenRow <= n; lenRow++)
    for (int lenCol = 1; lenCol <= m; lenCol++)
      for (int i = 1; i <= n - lenRow + 1; i++)
        for (int j = 1; j <= m - lenCol + 1; j++) {
          int i1 = i + lenRow - 1, j1 = j + lenCol - 1;
          sumSq[i][j][i1][j1] = hCur[i][j][i1][j1] + sumSq[i + 1][j][i1][j1] +
                                sumSq[i][j + 1][i1][j1] -
                                sumSq[i + 1][j + 1][i1][j1];
        }
  for (int i = 0; i < q; i++) {
    int r1, c1, r2, c2;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    printf("%d\n", sumSq[r1][c1][r2][c2]);
  }
}
