#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
const long long N = 42;
vector<string> mmap(N);
long long sum[N][N], sum1[N][N][N][N], sum2[N][N][N][N];
long long getsum(long long x1, long long y1, long long x2, long long y2) {
  return sum[x2 + 1][y2 + 1] - sum[x2 + 1][y1] - sum[x1][y2 + 1] + sum[x1][y1];
}
signed main() {
  cin >> n >> m >> q;
  for (long long i = 0; i < n; ++i) {
    cin >> mmap[i];
  }
  memset(sum, 0, sizeof(sum));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      sum[i + 1][j + 1] =
          sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + (mmap[i][j] - '0');
    }
  }
  memset(sum1, 0, sizeof(sum1));
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      for (long long u = i; u >= 0; --u) {
        for (long long v = j; v >= 0; --v) {
          sum1[i][j][u][v] = getsum(u, v, i, j) == 0;
          if (u < i) {
            sum1[i][j][u][v] += sum1[i][j][u + 1][v];
          }
          if (v < j) {
            sum1[i][j][u][v] += sum1[i][j][u][v + 1];
          }
          if (u < i && v < j) {
            sum1[i][j][u][v] -= sum1[i][j][u + 1][v + 1];
          }
        }
      }
    }
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      for (long long u = i; u < n; ++u) {
        for (long long v = j; v < m; ++v) {
          sum2[i][j][u][v] = sum1[u][v][i][j];
          if (u > i) {
            sum2[i][j][u][v] += sum2[i][j][u - 1][v];
          }
          if (v > j) {
            sum2[i][j][u][v] += sum2[i][j][u][v - 1];
          }
          if (u > i && v > j) {
            sum2[i][j][u][v] -= sum2[i][j][u - 1][v - 1];
          }
        }
      }
    }
  }
  while (q--) {
    long long i, j, u, v;
    cin >> i >> j >> u >> v;
    --i, --j, --u, --v;
    cout << sum2[i][j][u][v] << "\n";
  }
  return 0;
}
