#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n, m, q;
char s[N];
int a[N][N];
int d[N][N];
int w[N][N][N][N];
int dp[N][N][N][N];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; ++j) {
      a[i][j] = s[j] - '0';
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + a[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int x = 1; x <= i; ++x) {
        for (int y = 1; y <= j; ++y) {
          if (d[i][j] - (d[x - 1][j] + d[i][y - 1] - d[x - 1][y - 1]) == 0) {
            w[i][j][x][y] = 1;
          }
        }
        for (int y = j; y >= 1; --y) {
          w[i][j][x][y] += w[i][j][x][y + 1];
        }
      }
      for (int x = i; x >= 1; --x) {
        for (int y = 1; y <= j; ++y) {
          w[i][j][x][y] += w[i][j][x + 1][y];
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int x = i; x <= n; ++x) {
        for (int y = j; y <= m; ++y) {
          dp[i][j][x][y] = dp[i][j][x - 1][y] + dp[i][j][x][y - 1] -
                           dp[i][j][x - 1][y - 1] + w[x][y][i][j];
        }
      }
    }
  }
  for (int i = 0, a, b, c, d; i < q; ++i) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", dp[a][b][c][d]);
  }
  return 0;
}
