#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
struct HASH {
  size_t operator()(const pair<int, int>& x) const {
    return hash<long long>()(((long long)x.first) ^
                             (((long long)x.second) << 32));
  }
};
string inttostr(long long int n) {
  std::stringstream ss;
  ss << n;
  string out = ss.str();
  return out;
}
long long int stringtoint(string s) {
  istringstream iss(s);
  long long int n;
  iss >> n;
  return n;
}
template <typename T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
int row[505][505], col[505][505];
int grid[505][505], s[505][505], ss[505][505];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      grid[i][j] = (c == '.');
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] and grid[i][j + 1]) row[i][j] = 1;
      col[i][j] = (grid[i][j] and grid[i + 1][j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; j++) {
      s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + row[i][j];
      ss[i][j] = ss[i][j - 1] + ss[i - 1][j] - ss[i - 1][j - 1] + col[i][j];
    }
  }
  int k;
  cin >> k;
  while (k--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int ans = 0;
    ans = s[x2][y2 - 1] - s[x1 - 1][y2 - 1] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
    ans += ss[x2 - 1][y2] - ss[x1 - 1][y2] - ss[x2 - 1][y1 - 1] +
           ss[x1 - 1][y1 - 1];
    cout << ans << '\n';
  }
}
