#include <bits/stdc++.h>
using namespace std;
char grid[40][41];
bool isgood[50][50][50][50];
int sum[50][50][50][50];
int dp[50][50][50][50];
int main() {
  int n, m, q, r1, r2, c1, c2, ans;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", grid[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = i; k >= 0; k--)
        for (int l = j; l >= 0; l--) {
          sum[k][l][i][j] = sum[k][l + 1][i][j] + sum[k + 1][l][i][j] -
                            sum[k + 1][l + 1][i][j] + (grid[k][l] - '0');
          if (!sum[k][l][i][j]) isgood[k][l][i][j] = 1;
        }
  for (int k = 0; k < n; k++)
    for (int l = 0; l < m; l++)
      for (int i = k; i >= 0; i--)
        for (int j = l; j >= 0; j--)
          dp[i][j][k][l] = dp[i + 1][j][k][l] + dp[i][j + 1][k][l] -
                           dp[i + 1][j + 1][k][l] + isgood[i][j][k][l];
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    r1--;
    c1--;
    r2--;
    c2--;
    int ret = 0;
    for (int i = r1; i <= r2; i++)
      for (int j = c1; j <= c2; j++) ret += dp[r1][c1][i][j];
    printf("%d\n", ret);
  }
  return 0;
}
