#include <bits/stdc++.h>
using namespace std;
const int N = 40 + 5;
int t[N][N];
int dp[N][N][N][N];
int leftt[N][N];
int n, m, q;
int main() {
  char cc;
  cin >> n >> m >> q;
  for (int i = 1; i < n + 1; ++i)
    for (int j = 1; j < m + 1; ++j) {
      cin >> cc;
      t[i][j] = cc - '0';
      if (!t[i][j]) leftt[i][j] = leftt[i][j - 1] + 1;
    }
  int help;
  for (int a = 1; a < n + 1; ++a)
    for (int b = 1; b < m + 1; ++b)
      for (int c = a; c < n + 1; ++c)
        for (int d = b; d < m + 1; ++d) {
          dp[a][b][c][d] =
              dp[a][b][c - 1][d] + dp[a][b][c][d - 1] - dp[a][b][c - 1][d - 1];
          help = d - b + 1;
          for (int i = c; i > a - 1; --i) {
            help = min(help, leftt[i][d]);
            dp[a][b][c][d] += help;
          }
        }
  int a, b, c, d;
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", dp[a][b][c][d]);
  }
}
