#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const int mod = (int)(1e9 + 7);
int n, m, q;
int a[42][42];
char ch;
int h[42][42];
int dp[42][42][42][42];
int A, b, c, d;
int second[42];
int main() {
  ios::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) {
      cin >> ch;
      a[i][j] = ch - '0';
    }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == 0) {
        h[i][j] = h[i - 1][j] + 1;
      }
    }
  }
  stack<pair<int, int> > Q;
  for (int la = 1; la <= n; ++la)
    for (int lb = 1; lb <= m; ++lb) {
      for (int ra = la; ra <= n; ++ra) {
        while (!Q.empty()) Q.pop();
        ;
        for (int rb = lb; rb <= m; ++rb) {
          int x = min(ra - la + 1, h[ra][rb]);
          while (!Q.empty() && x <= Q.top().first) Q.pop();
          int sz = (int)Q.size();
          if (sz == 0)
            second[sz + 1] = second[sz] + x * (rb - lb + 1);
          else
            second[sz + 1] = second[sz] + x * (rb - Q.top().second);
          Q.push(make_pair(x, rb));
          dp[la][lb][ra][rb] = dp[la][lb][ra - 1][rb] + dp[la][lb][ra][rb - 1] -
                               dp[la][lb][ra - 1][rb - 1] + second[sz + 1];
        }
      }
    }
  for (int i = 1; i <= q; ++i) {
    cin >> A >> b >> c >> d;
    cout << dp[A][b][c][d] << "\n";
  }
  return 0;
}
