#include <bits/stdc++.h>
using namespace std;
const long long N = 42;
char a[N][N];
long long dp[N][N], i, j, n, m, q, u, v, k, l;
long long ans[N][N][N][N], a1, b1, a2, b2, c, val[N][N][N][N];
long long solve(long long i, long long j, long long k, long long l) {
  if (val[i][j][k][l] != -1) return val[i][j][k][l];
  val[i][j][k][l] = 0;
  if (!(dp[k][l] - dp[i - 1][l] - dp[k][j - 1] + dp[i - 1][j - 1]))
    ++val[i][j][k][l];
  val[i][j][k][l] += solve(i + 1, j, k, l) + solve(i, j + 1, k, l) +
                     solve(i, j, k - 1, l) + solve(i, j, k, l - 1);
  val[i][j][k][l] -= solve(i + 1, j + 1, k, l) + solve(i + 1, j, k - 1, l) +
                     solve(i + 1, j, k, l - 1);
  val[i][j][k][l] -= solve(i, j + 1, k - 1, l) + solve(i, j + 1, k, l - 1);
  val[i][j][k][l] -= solve(i, j, k - 1, l - 1);
  val[i][j][k][l] +=
      solve(i + 1, j + 1, k - 1, l) + solve(i + 1, j + 1, k, l - 1) +
      solve(i + 1, j, k - 1, l - 1) + solve(i, j + 1, k - 1, l - 1);
  val[i][j][k][l] -= solve(i + 1, j + 1, k - 1, l - 1);
  return val[i][j][k][l];
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> q;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) cin >> a[i][j];
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) {
      dp[i][j] +=
          dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + (a[i][j] == '1');
    }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      for (k = i; k <= n; ++k)
        for (l = j; l <= m; ++l) val[i][j][k][l] = -1;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      for (k = i; k <= n; ++k)
        for (l = j; l <= m; ++l) solve(i, j, k, l);
  while (q--) {
    cin >> a1 >> b1 >> a2 >> b2;
    cout << val[a1][b1][a2][b2] << "\n";
  }
  return 0;
}
