#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0;
  char c = getchar();
  int f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class T>
bool checkmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int mod = 1e9 + 7;
template <class T>
void my_add(T &a, T b) {
  a = a + b > mod ? a + b - mod : a + b;
}
template <class T>
void my_sub(T &a, T b) {
  a = a - b < 0 ? a - b + mod : a - b;
}
namespace moonpie {
const int N = 50;
int n, m, q;
char g[N][N];
int s[N][N], f[N][N][N][N], dp[N][N][N][N];
void solve() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", g[i] + 1);
    for (int j = 1; j <= m; ++j) {
      s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (g[i][j] - '0');
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int l = i; l <= n; ++l) {
        for (int r = j; r <= m; ++r) {
          f[i][j][l][r] =
              f[i][j][l - 1][r] + f[i][j][l][r - 1] - f[i][j][l - 1][r - 1];
          if (s[l][r] - s[l][j - 1] - s[i - 1][r] + s[i - 1][j - 1] == 0)
            f[i][j][l][r]++;
        }
      }
    }
  }
  for (int i = n; i >= 1; --i) {
    for (int j = m; j >= 1; --j) {
      for (int l = i; l <= n; ++l) {
        for (int r = j; r <= m; ++r) {
          dp[i][j][l][r] = dp[i + 1][j][l][r] + dp[i][j + 1][l][r] -
                           dp[i + 1][j + 1][l][r] + f[i][j][l][r];
        }
      }
    }
  }
  while (q--) printf("%d\n", dp[read()][read()][read()][read()]);
}
}  // namespace moonpie
signed main() {
  moonpie::solve();
  return 0;
}
