#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int S[42][42], A[42][42];
int f[42][42][42][42], g[42][42][42][42], kq[42][42][42][42];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char a;
      cin >> a;
      A[i][j] = (int)(a - '0');
      S[i][j] = S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1] + A[i][j];
    }
  }
  for (int i1 = 1; i1 <= n; i1++) {
    for (int j1 = 1; j1 <= m; j1++) {
      for (int i2 = i1; i2 <= n; i2++) {
        for (int j2 = j1; j2 <= m; j2++) {
          int sum =
              S[i2][j2] - S[i1 - 1][j2] - S[i2][j1 - 1] + S[i1 - 1][j1 - 1];
          f[i1][j1][i2][j2] = (sum == 0 ? 1 : 0);
        }
      }
    }
  }
  for (int i1 = n; i1 >= 1; i1--) {
    for (int j1 = m; j1 >= 1; j1--) {
      for (int i2 = i1; i2 <= n; i2++) {
        for (int j2 = j1; j2 <= m; j2++) {
          g[i1][j1][i2][j2] = g[i1 + 1][j1][i2][j2] + g[i1][j1 + 1][i2][j2] -
                              g[i1 + 1][j1 + 1][i2][j2] + f[i1][j1][i2][j2];
        }
      }
    }
  }
  for (int i1 = 1; i1 <= n; i1++) {
    for (int j1 = 1; j1 <= m; j1++) {
      for (int i2 = i1; i2 <= n; i2++) {
        for (int j2 = j1; j2 <= m; j2++) {
          kq[i1][j1][i2][j2] = kq[i1][j1][i2 - 1][j2] + kq[i1][j1][i2][j2 - 1] -
                               kq[i1][j1][i2 - 1][j2 - 1] + g[i1][j1][i2][j2];
        }
      }
    }
  }
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << kq[a][b][c][d] << '\n';
  }
  return 0;
}
