#include <bits/stdc++.h>
using namespace std;
const int N = 41;
char g[N][N];
int n, m, q, mat[N][N], a, b, c, d;
int res[N][N][N][N];
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> g[i][j];
      mat[i][j] =
          mat[i][j - 1] + mat[i - 1][j] - mat[i - 1][j - 1] + (g[i][j] - '0');
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = i; k <= n; k++)
        for (int l = j; l <= m; l++) {
          int x = mat[k][l] - mat[i - 1][l] - mat[k][j - 1] + mat[i - 1][j - 1];
          res[i][j][k][l] += res[i][j][k - 1][l] + res[i][j][k][l - 1] -
                             res[i][j][k - 1][l - 1] + !x;
        }
  while (q--) {
    cin >> a >> b >> c >> d;
    int ans = 0;
    for (int i = a; i <= c; i++)
      for (int j = b; j <= d; j++) ans += res[i][j][c][d];
    cout << ans << "\n";
  }
  return 0;
}
