#include <bits/stdc++.h>
using namespace std;
const int N = 41;
int dp[N][N][N][N];
char arr[N][N];
int cum[N][N];
int n, m, q;
bool allZeros(int i, int j, int x, int y) {
  int lenA = x - i + 1, lenB = y - j + 1, tot = lenA * lenB;
  return tot == (cum[x][y] - cum[x][j - 1] - cum[i - 1][y] + cum[i - 1][j - 1]);
}
int solve(int i, int j, int x, int y) {
  if (x < i || y < j) return 0;
  if (dp[i][j][x][y] != -1) return dp[i][j][x][y];
  return dp[i][j][x][y] =
             (0LL + allZeros(i, j, x, y) + solve(i, j + 1, x, y) +
              solve(i, j, x, y - 1) + solve(i + 1, j, x, y) +
              solve(i, j, x - 1, y) - solve(i, j + 1, x, y - 1) -
              solve(i + 1, j + 1, x, y) - solve(i, j + 1, x - 1, y) -
              solve(i, j, x - 1, y - 1) - solve(i + 1, j, x, y - 1) -
              solve(i + 1, j, x - 1, y) + solve(i, j + 1, x - 1, y - 1) +
              solve(i + 1, j + 1, x, y - 1) + solve(i + 1, j + 1, x - 1, y) +
              solve(i + 1, j, x - 1, y - 1) -
              solve(i + 1, j + 1, x - 1, y - 1));
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", arr[i] + 1);
    for (int j = 1; j <= m; j++) {
      cum[i][j] = cum[i - 1][j] + cum[i][j - 1] - cum[i - 1][j - 1] +
                  (arr[i][j] == '0');
    }
  }
  memset(dp, -1, sizeof dp);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", solve(a, b, c, d));
  }
  return 0;
}
