#include <bits/stdc++.h>
using namespace std;
int n, m, q, sum[44][44], cnt[44][44][44][44];
string a[44];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      sum[i + 1][j + 1] =
          sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + (a[i][j] == '1');
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int x = i; x <= n; x++) {
        for (int y = j; y <= m; y++) {
          int ok =
              sum[x][y] - sum[i - 1][y] - sum[x][j - 1] + sum[i - 1][j - 1];
          cnt[i][j][x][y] = cnt[i][j][x - 1][y] + cnt[i][j][x][y - 1] -
                            cnt[i][j][x - 1][y - 1] + (!ok);
        }
      }
    }
  }
  while (q--) {
    int x, y, x2, y2, ans = 0;
    cin >> x >> y >> x2 >> y2;
    for (int i = x; i <= x2; i++) {
      for (int j = y; j <= y2; j++) {
        ans += cnt[i][j][x2][y2];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
