#include <bits/stdc++.h>
using vi = std::vector<long long int>;
using vvi = std::vector<vi>;
using pii = std::pair<long long int, long long int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
using namespace std;
const long long int N = 41 + 10;
const long long int inf = 1e18 + 10;
const long double Pi = 3.14159265;
long long int n, m, q, dp[N][N][N][N], len, x, y, z, w, cnt[N][N], taka;
char c[N][N];
void solve() {
  cin >> n >> m >> q;
  for (long long int i = 1; i <= n; i++)
    for (long long int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == '0') cnt[i][j] = cnt[i][j - 1] + 1;
    }
  for (long long int i = 1; i <= n; i++)
    for (long long int j = 1; j <= m; j++)
      for (long long int r = i; r <= n; r++)
        for (long long int c = j; c <= m; c++) {
          dp[i][j][r][c] =
              dp[i][j][r - 1][c] + dp[i][j][r][c - 1] - dp[i][j][r - 1][c - 1];
          taka = 0;
          len = inf;
          for (long long int zz = r; zz >= i; zz--)
            len = min(len, cnt[zz][c]), taka += min(len, c - j + 1);
          dp[i][j][r][c] += taka;
        }
  for (long long int i = 1; i <= q; i++) {
    cin >> x >> y >> z >> w;
    cout << dp[x][y][z][w];
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
  long long int xx = 0;
  long long int t;
  cin >> t;
  while (t--) {
    ;
    solve();
    cout << endl;
  }
  return 0;
}
