#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int B[45][45], Tot[45][45][45][45], S[45][45], H, W, Q;
vector<pair<int, int>> R[45][45];
int am(int i1, int j1, int i2, int j2) {
  return S[i2][j2] - S[i2][j1 - 1] - S[i1 - 1][j2] + S[i1 - 1][j1 - 1];
}
int main() {
  cin >> H >> W >> Q;
  for (int i = (1); i <= (H); i++) {
    string s;
    cin >> s;
    for (int j = (1); j <= (W); j++) B[i][j] = s[j - 1] - '0';
  }
  for (int i = (1); i <= (H); i++)
    for (int j = (1); j <= (W); j++)
      S[i][j] = S[i][j - 1] + S[i - 1][j] - S[i - 1][j - 1] + B[i][j];
  for (int i1 = (1); i1 <= (H); i1++)
    for (int j1 = (1); j1 <= (W); j1++)
      for (int i2 = (i1); i2 <= (H); i2++)
        for (int j2 = (j1); j2 <= (W); j2++)
          if (am(i1, j1, i2, j2) == 0) R[i2][j2].push_back({i1, j1});
  for (int i1 = (1); i1 <= (H); i1++)
    for (int j1 = (1); j1 <= (W); j1++)
      for (int i2 = (i1); i2 <= (H); i2++)
        for (int j2 = (j1); j2 <= (W); j2++) {
          Tot[i1][j1][i2][j2] = Tot[i1][j1][i2 - 1][j2] +
                                Tot[i1][j1][i2][j2 - 1] -
                                Tot[i1][j1][i2 - 1][j2 - 1];
          for (pair<int, int> p : R[i2][j2])
            if (p.first >= i1 && p.second >= j1) Tot[i1][j1][i2][j2]++;
        }
  while (Q--) {
    int i1, j1, i2, j2;
    scanf("%d %d %d %d", &i1, &j1, &i2, &j2);
    printf("%d\n", Tot[i1][j1][i2][j2]);
  }
}
