#include <bits/stdc++.h>
using namespace std;
const long long N = 45;
long long p[N][N][N][N];
long long a[N][N], pref[N][N];
long long cache[N][N][N][N];
int32_t main() {
  memset(cache, -1, sizeof cache);
  long long n, m, q;
  scanf("%lld %lld %lld", &n, &m, &q);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      char x;
      cin >> x;
      a[i][j] = (x == '0' ? 1 : 0);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++)
      pref[i][j] =
          pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1] + a[i][j];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (a[i][j] == 0) continue;
      for (long long k = i; k <= n; k++) {
        for (long long l = j; l <= m; l++) {
          long long diff = (k - i + 1) * (l - j + 1);
          if (diff == pref[k][l] - pref[k][j - 1] - pref[i - 1][l] +
                          pref[i - 1][j - 1]) {
            p[i][j][k][l] = 1;
          }
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (a[i][j] == 0) continue;
      for (long long k = i; k <= n; k++) {
        for (long long l = j; l <= m; l++) {
          p[i][j][k][l] = p[i][j][k - 1][l] + p[i][j][k][l - 1] -
                          p[i][j][k - 1][l - 1] + p[i][j][k][l];
        }
      }
    }
  }
  while (q--) {
    long long ans = 0;
    long long x1, y1, x2, y2;
    scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
    if (cache[x1][y1][x2][y2] != -1) {
      printf("%lld\n", cache[x1][y1][x2][y2]);
      continue;
    }
    for (long long i = x1; i <= x2; i++) {
      for (long long j = y1; j <= y2; j++) {
        if (a[i][j])
          ans += p[i][j][x2][y2] - p[i][j][x2][y1 - 1] - p[i][j][x1 - 1][y2] +
                 p[i][j][x1 - 1][y1 - 1];
      }
    }
    cache[x1][y1][x2][y2] = ans;
    printf("%lld\n", ans);
  }
  return 0;
}
