#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(const long long &a, const long long &b) {
  return (a / gcd(a, b)) * b;
}
bool check(long long a) {
  int k = 0;
  while (a > 0) {
    if (!(a & 1)) {
      k++;
    }
    a >>= 1;
  }
  return k == 1;
}
int bits(long long a) {
  int k = 0;
  if (a == 0) {
    return 1;
  }
  while (a > 0) {
    k++;
    a >>= 1;
  }
  return k;
}
int main() {
  int h, w;
  cin >> h >> w;
  char c;
  vector<vector<int>> a(h + 2, vector<int>(w + 2, 1));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c;
      if (c == '.') {
        a[i][j] = 0;
      } else
        a[i][j] = 1;
    }
  }
  vector<vector<pair<int, int>>> v(h + 2, vector<pair<int, int>>(w + 2));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      v[i][j].first = v[i][j - 1].first + (a[i][j - 1] + a[i][j] == 0 ? 1 : 0);
    }
  }
  for (int j = 1; j <= w; j++) {
    for (int i = 1; i <= h; i++) {
      v[i][j].second =
          v[i - 1][j].second + (a[i - 1][j] + a[i][j] == 0 ? 1 : 0);
    }
  }
  int q;
  cin >> q;
  int l1, r1, l2, r2;
  int ans = 0, s1, s2;
  for (int i = 0; i < q; i++) {
    cin >> l1 >> r1 >> l2 >> r2;
    ans = 0;
    s1 = 0;
    s2 = 0;
    for (int j = l1; j <= l2; j++) {
      s1 = v[j][r2].first - v[j][r1].first;
      ans += s1;
    }
    for (int j = r1; j <= r2; j++) {
      s2 = v[l2][j].second - v[l1][j].second;
      ans += s2;
    }
    cout << ans << endl;
  }
  return 0;
}
