#include <bits/stdc++.h>
using namespace std;
const int maxn = 44;
char s[maxn][maxn];
int tes[maxn][maxn], lef[maxn][maxn], up[maxn][maxn];
int res[maxn][maxn][maxn][maxn], opt[maxn][maxn][maxn][maxn], n, m, q;
int sum[maxn][maxn], row[maxn][maxn][maxn], ans[maxn][maxn][maxn][maxn];
int main() {
  while (scanf("%d%d%d", &n, &m, &q) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%s", s[i]);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) tes[i][j] = (s[i][j - 1] - '0');
    memset(up, 0, sizeof(up));
    memset(lef, 0, sizeof(lef));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        sum[i][j] =
            sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + tes[i][j];
    memset(opt, 0, sizeof(opt));
    memset(res, 0, sizeof(res));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        for (int k = i; k >= 1; k--)
          for (int l = j; l >= 1; l--) {
            if (sum[i][j] - sum[k - 1][j] - sum[i][l - 1] + sum[k - 1][l - 1] ==
                0)
              opt[i][j][k][l] = 1;
            res[i][j][k][l] = res[i][j][k + 1][l] + res[i][j][k][l + 1] -
                              res[i][j][k + 1][l + 1] + opt[i][j][k][l];
          }
    memset(ans, 0, sizeof(ans));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        for (int k = 1; k <= i; k++) {
          for (int l = 1; l <= j; l++) {
            ans[i][j][k][l] = ans[i - 1][j][k][l] + ans[i][j - 1][k][l] -
                              ans[i - 1][j - 1][k][l] + res[i][j][k][l];
          }
        }
      }
    for (int i = 1; i <= q; i++) {
      int xa, ya, xb, yb;
      scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
      printf("%d\n", ans[xb][yb][xa][ya]);
    }
  }
}
