#include <bits/stdc++.h>
using namespace std;
const int N = 41;
int n, m, q, bct[N][N], cnt[N][N][N][N], dp[N][N][N][N];
char str[45];
void solve() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    int tmp = 0;
    for (int j = 0; j < m; j++) {
      if (str[j] == '0') ++tmp;
      bct[i][j + 1] = bct[i - 1][j + 1] + tmp;
    }
  }
  int ti, tj, tot;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int p = 1; p <= i; p++) {
        for (int q = 1; q <= j; q++) {
          ti = i - p;
          tj = j - q;
          cnt[i][j][p][q] = cnt[i][j][p - 1][q] + cnt[i][j][p][q - 1] -
                            cnt[i][j][p - 1][q - 1];
          if (bct[i][j] - bct[ti][j] - bct[i][tj] + bct[ti][tj] == p * q)
            ++cnt[i][j][p][q];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int p = 1; p <= i; p++) {
        for (int q = 1; q <= j; q++) {
          int tmp = dp[i - 1][j][p - 1][q];
          for (int k = 1; k <= q; k++) {
            tmp += cnt[i][j - k + 1][p][q - k + 1];
          }
          dp[i][j][p][q] = tmp;
        }
      }
    }
  }
  int a, b, c, d;
  while (q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", dp[c][d][c - a + 1][d - b + 1]);
  }
}
int main() {
  solve();
  return 0;
}
