#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int dp[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 i1, int j1, int i2, int j2) {
  if (i2 < i1 || j2 < j1) return 0;
  int &ret = dp[i1][j1][i2][j2];
  if (ret != -1) return ret;
  ret = 0;
  ret += beut[i1][j1][i2][j2];
  for (int i = 0; i < 2; i++) ret += solve(i1, j1, i2 + sx[i], j2 + sy[i]);
  ret -= solve(i1, j1, i2 + sx[2], j2 + sy[2]);
  return 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);
  int a2, a1, b1, b2;
  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++) solve(i1, j1, i2, j2);
  for (int i = 0; i < q; i++) {
    cin >> a1 >> b1 >> a2 >> b2;
    long long ret = 0;
    for (int i = a1; i <= a2; i++)
      for (int j = b1; j <= b2; j++) ret += dp[i][j][a2][b2];
    cout << ret << endl;
  }
}
