#include <bits/stdc++.h>
using namespace std;
int n, m, q;
long long dp[42][42][42][42], accc[42][42][42][42];
int acc[42][42], arr[42][42];
int beut[42][42][42][42];
int sx[] = {-1, 0, -1};
int sy[] = {0, -1, -1};
int solve(int a, int b, int c, int d) {
  if (dp[a][b][c][d] != -1) return dp[a][b][c][d];
  int ret = beut[a][b][c][d];
  if (c > a) ret += solve(a, b, c - 1, d);
  if (d > b) ret += solve(a, b, c, d - 1);
  if (c > a && d > b) ret -= solve(a, b, c - 1, d - 1);
  return dp[a][b][c][d] = ret;
}
int main() {
  cin >> n >> m >> q;
  n++;
  m++;
  string s;
  for (int i = 1; i < n; i++) {
    cin >> s;
    for (int j = 1; j < m; j++) {
      arr[i][j] = s[j - 1] - '0';
    }
  }
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) {
      acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1] + arr[i][j];
    }
  for (int i1 = 1; i1 < n; i1++)
    for (int i2 = i1; i2 < n; i2++)
      for (int j1 = 1; j1 < m; j1++)
        for (int j2 = j1; j2 < m; j2++) {
          int sum = acc[i2][j2] + acc[i1 - 1][j1 - 1] - acc[i2][j1 - 1] -
                    acc[i1 - 1][j2];
          if (sum == 0) {
            beut[i1][j1][i2][j2] = 1;
          }
        }
  memset(dp, -1, sizeof dp);
  while (q--) {
    int ai, bi, ci, di;
    scanf("%d %d %d %d", &ai, &bi, &ci, &di);
    int res = 0;
    for (int i = ai; i <= ci; i++)
      for (int j = bi; j <= di; j++) {
        res += solve(i, j, ci, di);
      }
    printf("%d\n", res);
  }
}
