#include <bits/stdc++.h>
using namespace std;
int n, m, q, a, b, c, d, dp[50][50][50][50], A[50][50];
string s[50];
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i <= n - 1; i++) cin >> s[i];
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= m - 1; j++)
      A[i + 1][j + 1] = (A[i + 1][j] + 1) * (s[i][j] == '0');
  for (int w = 1; w <= m; w++)
    for (int h = 1; h <= n; h++)
      for (int i = 1; i <= n - h + 1; i++)
        for (int j = 1; j <= m - w + 1; j++) {
          dp[i][i + h - 1][j][j + w - 1] = dp[i][i + h - 1][j][j + w - 2] +
                                           dp[i][i + h - 2][j][j + w - 1] -
                                           dp[i][i + h - 2][j][j + w - 2];
          for (int k = i + h - 1, C = w; k >= i; C = min(C, A[k][j + w - 1]),
                   dp[i][i + h - 1][j][j + w - 1] += C, k--)
            ;
        }
  for (int i = 1; i <= q; i++)
    cin >> a >> b >> c >> d, cout << dp[a][c][b][d] << endl;
}
