#include <bits/stdc++.h>
const int N = 42;
int s[N][N];
char str[N];
int Cal(int x0, int y0, int x1, int y1) {
  x0--;
  y0--;
  return s[x1][y1] - s[x0][y1] - s[x1][y0] + s[x0][y0];
}
int dp[N][N][N][N];
int val[N][N][N][N];
int main() {
  int n, m, q, i, j;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) {
    scanf("%s", str);
    for (j = 0; j < m; j++) s[i][j + 1] = s[i][j] + str[j] - '0';
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) s[i][j] += s[i - 1][j];
  int x0, x1, y0, y1;
  for (x0 = 1; x0 <= n; x0++)
    for (x1 = x0; x1 <= n; x1++)
      for (y0 = 1; y0 <= m; y0++)
        for (y1 = y0; y1 <= m; y1++)
          if (Cal(x0, y0, x1, y1) == 0) val[x0][y0][x1][y1]++;
  for (x1 = 1; x1 <= n; x1++)
    for (y1 = 1; y1 <= m; y1++) {
      for (i = n; i >= 1; i--)
        for (j = m; j >= 1; j--) val[i][j - 1][x1][y1] += val[i][j][x1][y1];
      for (i = n; i >= 1; i--)
        for (j = m; j >= 1; j--) val[i - 1][j][x1][y1] += val[i][j][x1][y1];
    }
  for (x0 = 1; x0 <= n; x0++)
    for (x1 = x0; x1 <= n; x1++)
      for (y0 = 1; y0 <= m; y0++)
        for (y1 = y0; y1 <= m; y1++)
          dp[x0][x1][y0][y1] = dp[x0][x1 - 1][y0][y1] + dp[x0][x1][y0][y1 - 1] -
                               dp[x0][x1 - 1][y0][y1 - 1] + val[x0][y0][x1][y1];
  while (q--) {
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
    printf("%d\n", dp[x0][x1][y0][y1]);
  }
  return 0;
}
