#include <bits/stdc++.h>
using namespace std;
const int N = 55;
char v[N][N];
long long dp[N][N][N][N], h[N][N], nr[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> (v[i] + 1);
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      h[i][j] = (v[i][j] == '0') ? 1 + h[i - 1][j] : 0;
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++) {
      memset(nr, 0, sizeof(nr));
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) {
          if (a == 2 && b == 3) int debug = 1;
          long long Min = h[c][d];
          if (Min > c - a + 1) Min = c - a + 1;
          for (int j = d; j >= b; j--) {
            dp[a][b][c][d] += nr[j] + Min;
            nr[d] += Min;
            Min = min(Min, h[c][j - 1]);
          }
        }
    }
  for (int i = 1; i <= q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << dp[a][b][c][d] << "\n";
  }
}
