#include <bits/stdc++.h>
using namespace std;
const int N = 40 + 5;
int sum[N][N], dp[N][N][N][N];
bool allzero(int r1, int c1, int r2, int c2) {
  return ((sum[r2][c2] - sum[r2][c1 - 1] - sum[r1 - 1][c2] +
           sum[r1 - 1][c1 - 1]) == 0);
}
int main() {
  int n, m, q, r1, c1, r2, c2;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch;
      scanf(" %c", &ch);
      sum[i][j] =
          (ch == '1') + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j][i][j] = allzero(i, j, i, j);
      for (int jx = j - 1; jx > 0; jx--) {
        dp[i][j][i][jx] = allzero(i, jx, i, j) + dp[i][j][i][jx + 1];
      }
      for (int ix = i - 1; ix > 0; ix--) {
        dp[i][j][ix][j] = allzero(ix, j, i, j) + dp[i][j][ix + 1][j];
      }
      for (int ix = i - 1; ix > 0; ix--) {
        for (int jx = j - 1; jx > 0; jx--) {
          dp[i][j][ix][jx] = allzero(ix, jx, i, j) + dp[i][j][ix][jx + 1] +
                             dp[i][j][ix + 1][jx] - dp[i][j][ix + 1][jx + 1];
        }
      }
    }
  }
  int ans = 0;
  while (q--) {
    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    ans = 0;
    for (int i = r1; i <= r2; i++) {
      for (int j = c1; j <= c2; j++) {
        ans += dp[i][j][r1][c1];
      }
    }
    printf("%d\n", ans);
  }
}
