#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int hash_mod = 1000037;
const double pi = acos(-1);
const double eps = 1e-10;
const int maxn = 40 + 2;
int n, m, q;
char g[maxn][maxn];
int h[maxn];
int f[maxn][maxn][maxn][maxn];
int pre[maxn][maxn][maxn][maxn];
void init() {
  for (int b = 1; b <= n; ++b)
    for (int l = 1; l <= m; ++l)
      for (int r = l; r <= m; ++r) {
        for (int j = l; j <= r; ++j) {
          int i = b;
          while (i > 0 && g[i][j] == '0') --i;
          h[j] = b - i;
        }
        for (int v = 1; v <= b; ++v) {
          int &t = f[b][l][r][v];
          t = 0;
          int p = l;
          while (true) {
            while (p <= r && h[p] < v) ++p;
            if (p > r) break;
            int q = p + 1;
            while (q <= r && h[q] >= v) ++q;
            int d = q - p;
            t += d * (d + 1) / 2;
            p = q;
          }
          pre[b][l][r][v] = pre[b - 1][l][r][v] + t;
        }
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
  init();
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int res = 0;
    for (int v = 1; v <= c - a + 1; ++v)
      res += pre[c][b][d][v] - pre[a + v - 2][b][d][v];
    printf("%d\n", res);
  }
  return 0;
}
