#include <bits/stdc++.h>
using namespace std;
const int maxn = 45;
const int mod = 1e9 + 7;
int n, m, ans, q;
int dp[maxn][maxn][maxn][maxn], a[maxn][maxn], A[maxn][maxn];
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
      int k = j;
      while (!a[i][k] && k) k--;
      A[i][j] = j - k;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = i; k <= n; k++)
        for (int l = j; l <= m; l++) {
          dp[i][j][k][l] =
              dp[i][j][k - 1][l] + dp[i][j][k][l - 1] - dp[i][j][k - 1][l - 1];
          int tmp = l - j + 1;
          for (int o = 0; k - o >= i; o++) {
            tmp = min(tmp, A[k - o][l]);
            dp[i][j][k][l] += tmp;
          }
        }
  while (q--) {
    int x, y, z, w;
    cin >> x >> y >> z >> w;
    cout << dp[x][y][z][w] << endl;
  }
  return 0;
}
