#include <bits/stdc++.h>
using namespace std;
int n, m, q;
string B[41];
int sum[41][41], cnt[41][41][41][41], a[41][41];
int main(int argv, char *argc[]) {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    cin >> B[i];
    for (int j = 1; j <= m; j++) {
      a[i][j] = (B[i][j - 1] == '1');
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0) {
        sum[i][j] = 0;
      } else {
        sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
      }
    }
  }
  for (int xa = 1; xa <= n; xa++) {
    for (int ya = 1; ya <= m; ya++) {
      for (int xb = xa; xb <= n; xb++) {
        for (int yb = ya; yb <= m; yb++) {
          int nsum = sum[xb][yb] - sum[xa - 1][yb] - sum[xb][ya - 1] +
                     sum[xa - 1][ya - 1];
          cnt[xa][ya][xb][yb] = (nsum == 0);
        }
      }
    }
  }
  for (int xa = n; xa > 1; xa--) {
    for (int ya = 1; ya <= m; ya++) {
      for (int xb = xa; xb <= n; xb++) {
        for (int yb = ya; yb <= m; yb++) {
          cnt[xa - 1][ya][xb][yb] += cnt[xa][ya][xb][yb];
        }
      }
    }
  }
  for (int xa = 1; xa <= n; xa++) {
    for (int ya = m; ya > 1; ya--) {
      for (int xb = xa; xb <= n; xb++) {
        for (int yb = ya; yb <= m; yb++) {
          cnt[xa][ya - 1][xb][yb] += cnt[xa][ya][xb][yb];
        }
      }
    }
  }
  for (int xa = 1; xa <= n; xa++) {
    for (int ya = 1; ya <= m; ya++) {
      for (int xb = xa; xb <= n; xb++) {
        for (int yb = ya; yb <= m; yb++) {
          cnt[xa][ya][xb + 1][yb] += cnt[xa][ya][xb][yb];
        }
      }
    }
  }
  for (int xa = 1; xa <= n; xa++) {
    for (int ya = 1; ya <= m; ya++) {
      for (int xb = xa; xb <= n; xb++) {
        for (int yb = ya; yb <= m; yb++) {
          cnt[xa][ya][xb][yb + 1] += cnt[xa][ya][xb][yb];
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << cnt[a][b][c][d] << '\n';
  }
  return 0;
}
