#include <bits/stdc++.h>
using namespace std;
const int Max = 40 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
int cum[Max][Max];
int cnt[Max][Max][Max][Max];
char ch[Max][Max];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q, a, b, c, d;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> ch[i][j];
      cum[i][j] = cum[i][j - 1] + (ch[i][j] == '1');
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int mp[Max] = {0};
      for (int k = i; k <= n; k++) {
        for (int l = j; l <= m; l++) {
          int ans = 0;
          for (int m = j; m <= l; m++) {
            cnt[i][j][k][l] += mp[m];
          }
          for (int m = i; m <= k; m++) {
            ans += cum[m][l] - cum[m][j - 1];
          }
          if (ans == 0) {
            cnt[i][j][k][l] += 1;
            mp[l] += 1;
          }
        }
      }
    }
  }
  while (q--) {
    int ans = 0;
    cin >> a >> b >> c >> d;
    for (int i = a; i <= c; i++) {
      for (int j = b; j <= d; j++) {
        ans += cnt[i][j][c][d];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
