#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int a[45][45], cnt[45][45][45][45];
int s[45][45], sum[45][45][45][45];
int main() {
  int n, m, cs;
  scanf("%d%d%d", &n, &m, &cs);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
    }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      for (int r = i; r <= n; r++)
        for (int c = j; c <= m; c++) {
          int dot = s[r][c] - s[r][j - 1] - s[i - 1][c] + s[i - 1][j - 1];
          cnt[i][j][r][c] = cnt[i][j][r - 1][c] + cnt[i][j][r][c - 1] -
                            cnt[i][j][r - 1][c - 1] + !dot;
        }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      for (int r = i; r <= n; r++)
        for (int c = j; c <= m; c++)
          sum[i][j][r][c] = sum[i + 1][j][r][c] + sum[i][j + 1][r][c] -
                            sum[i + 1][j + 1][r][c] + cnt[i][j][r][c];
  while (cs--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", sum[a][b][c][d]);
  }
}
