#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
int n, m, q, a, b, c, d;
char ch;
long long dps[55][55], dp[55][55][55][55];
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> ch;
      dps[i][j] = dps[i][j - 1] + 1;
      if (ch == '1') {
        dps[i][j] = 0;
      }
    }
  }
  for (int a = 1; a <= n; a++) {
    for (int b = 1; b <= m; b++) {
      for (int c = a; c <= n; c++) {
        for (int d = b; d <= m; d++) {
          dp[a][b][c][d] =
              dp[a][b][c][d - 1] + dp[a][b][c - 1][d] - dp[a][b][c - 1][d - 1];
          long long cnt = d - b + 1;
          for (int i = c; i >= a; i--) {
            cnt = min(cnt, dps[i][d]);
            dp[a][b][c][d] += cnt;
          }
        }
      }
    }
  }
  while (q--) {
    cin >> a >> b >> c >> d;
    cout << dp[a][b][c][d] << '\n';
  }
  return 0;
}
