#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
int upmin(T1 &x, T2 v) {
  if (x > v) {
    x = v;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
int upmax(T1 &x, T2 v) {
  if (x < v) {
    x = v;
    return 1;
  }
  return 0;
}
const int INF = 0x3f3f3f3f;
int N, M, Q;
vector<string> G;
void init() {
  cin >> N >> M >> Q;
  G = vector<string>(N);
  for (int i = 0; i < N; ++i) {
    cin >> G[i];
  }
}
int dp[40 + 1][40 + 1][40 + 1][40 + 1];
int pdp[40 + 1][40 + 1][40 + 1][40 + 1];
int ans[40 + 2][40 + 2][40 + 2][40 + 2];
void preprocess() {
  for (int i = 0; i <= 40; ++i) {
    for (int j = 0; j <= 40; ++j) {
      for (int k = 0; k <= 40; ++k) {
        for (int l = 0; l <= 40; ++l) {
          if (k <= i and l <= j) continue;
          dp[i][j][k][l] = 1;
        }
      }
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      for (int k = i; k >= 0; --k) {
        for (int l = j; l >= 0; --l) {
          dp[i + 1][j + 1][k + 1][l + 1] = dp[i][j + 1][k + 1][l + 1] &
                                           dp[i + 1][j][k + 1][l + 1] &
                                           (G[i][j] == '0');
        }
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      for (int k = i; k >= 1; --k) {
        for (int l = j; l >= 1; --l) {
          pdp[i][j][k][l] = pdp[i - 1][j][k][l] + pdp[i][j - 1][k][l] -
                            pdp[i - 1][j - 1][k][l] + dp[i][j][k][l];
        }
      }
    }
  }
  for (int i = N; i >= 1; --i) {
    for (int j = M; j >= 1; --j) {
      for (int k = i; k >= 1; --k) {
        for (int l = j; l >= 1; --l) {
          ans[i][j][k][l] = ans[i][j][k + 1][l] + ans[i][j][k][l + 1] -
                            ans[i][j][k + 1][l + 1] + pdp[i][j][k][l];
        }
      }
    }
  }
}
void solve() {
  for (int kase = 0; kase < Q; ++kase) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << ans[C][D][A][B] << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  init();
  preprocess();
  solve();
  return 0;
}
