#include <bits/stdc++.h>
using namespace std;
const int NMax = 41;
const int INF = int(1e9);
const int sizeTree = 262145;
const double eps = 1e-9;
const double PI = 3.141592653589793238462;
const int MOD = int(1e9);
char ch[NMax][NMax];
int dp[NMax][NMax][NMax][NMax], s[NMax][NMax];
int n, m, l1, r1, l2, r2, q;
int solve(int i, int j, int k, int l) {
  if (i > k || j > l) return 0;
  if (i == k && j == l) {
    if (ch[i][j] == '0')
      dp[i][j][k][l] = 1;
    else
      dp[i][j][k][l] = 0;
    return dp[i][j][k][l];
  }
  if (dp[i][j][k][l] != -1) return dp[i][j][k][l];
  dp[i][j][k][l] = 0;
  if (i == k)
    dp[i][j][k][l] = solve(i, j + 1, k, l) + solve(i, j, k, l - 1) -
                     solve(i, j + 1, k, l - 1);
  else if (j == l)
    dp[i][j][k][l] = solve(i + 1, j, k, l) + solve(i, j, k - 1, l) -
                     solve(i + 1, j, k - 1, l);
  else {
    dp[i][j][k][l] =
        solve(i + 1, j, k, l) + solve(i, j + 1, k, l) + solve(i, j, k - 1, l) +
        solve(i, j, k, l - 1) - solve(i + 1, j + 1, k, l) -
        solve(i + 1, j, k - 1, l) - solve(i + 1, j, k, l - 1) -
        solve(i, j + 1, k - 1, l) - solve(i, j + 1, k, l - 1) -
        solve(i, j, k - 1, l - 1) + solve(i + 1, j + 1, k - 1, l) +
        solve(i + 1, j + 1, k, l - 1) + solve(i, j + 1, k - 1, l - 1) +
        solve(i + 1, j, k - 1, l - 1) - solve(i + 1, j + 1, k - 1, l - 1);
  }
  if (s[k][l] - s[i - 1][l] - s[k][j - 1] + s[i - 1][j - 1] == 0)
    dp[i][j][k][l]++;
  return dp[i][j][k][l];
}
int main() {
  scanf("%i%i%i\n", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%c", &ch[i][j]);
    scanf("\n");
  }
  memset(dp, -1, sizeof(dp));
  memset(s, 0, sizeof(s));
  if (ch[1][1] == '1')
    s[1][1] = 1;
  else
    s[1][1] = 0;
  for (int i = 2; i <= n; i++) {
    s[i][1] = s[i - 1][1];
    if (ch[i][1] == '1') s[i][1]++;
  }
  for (int i = 2; i <= m; i++) {
    s[1][i] = s[1][i - 1];
    if (ch[1][i] == '1') s[1][i]++;
  }
  for (int i = 2; i <= n; i++)
    for (int j = 2; j <= m; j++) {
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
      if (ch[i][j] == '1') s[i][j]++;
    }
  dp[1][1][n][m] = solve(1, 1, n, m);
  for (int i = 1; i <= q; i++) {
    scanf("%i%i%i%i", &l1, &r1, &l2, &r2);
    printf("%i\n", dp[l1][r1][l2][r2]);
  }
  return 0;
}
