#include <bits/stdc++.h>
using namespace std;
template <typename T>
T prod(const T &a, const T &b, const T &mod) {
  return ((a % mod) * (b % mod)) % mod;
}
template <typename T>
T pow_(const T &a, const T &b) {
  if (!b) return 1;
  T p = pow_(a, b / 2);
  p *= p;
  return (b % 2) ? (p * a) : p;
}
template <typename T>
T modpow(const T &a, const T &b, const T &mod) {
  if (!b) return 1;
  T p = modpow(a, b / 2);
  p = prod(p, p);
  return (b % 2) ? (prod(p, a)) : p;
}
template <typename T>
T max(const T &a, const T &b, const T &c) {
  return max(a, max(b, c));
}
template <typename T>
T min(const T &a, const T &b, const T &c) {
  return min(a, min(b, c));
}
template <typename T>
void dbg(const vector<T> &a, int l, int r) {
  for (long long int i = l; i <= r; i++) cout << a[i] << " ";
  cout << endl;
}
template <typename T>
void dbg(const vector<T> &a) {
  for (long long int i = 0; i <= a.size() - 1; i++) cout << a[i] << " ";
  cout << endl;
}
void main_() {
  long long int n, m;
  cin >> n >> m;
  long long int mat[n + 1][m + 1], row[n + 1][m + 1], col[n + 1][m + 1];
  for (long long int i = 0; i <= n; i++) {
    if (i == 0)
      for (long long int j = 0; j <= m; j++) mat[i][j] = 0;
    else {
      string s;
      cin >> s;
      mat[i][0] = 0;
      for (long long int j = 1; j <= m; j++) mat[i][j] = (s[j - 1] == '.');
    }
    for (long long int j = 0; j <= m; j++) row[i][j] = col[i][j] = 0;
  }
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 1; j <= m; j++)
      if (mat[i][j] && mat[i][j - 1]) row[i][j] = 1;
    for (long long int j = 1; j <= m; j++) row[i][j] += row[i][j - 1];
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j <= m; j++)
      if (mat[i][j] && mat[i - 1][j]) col[i][j] = 1;
    for (long long int j = 0; j <= m; j++) col[i][j] += col[i - 1][j];
  }
  long long int q;
  cin >> q;
  while (q--) {
    long long int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    long long int ans = 0;
    for (long long int i = x1; i <= x2; i++) ans += row[i][y2] - row[i][y1];
    for (long long int i = y1; i <= y2; i++) ans += col[x2][i] - col[x1][i];
    cout << ans << endl;
  }
}
int main() {
  { main_(); }
  return 0;
}
