#include <bits/stdc++.h>
using namespace std;
long long MOD = 10e9 + 7;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, R, C, q;
  cin >> R >> C;
  string a[R];
  for (i = 0; i < R; i++) {
    cin >> a[i];
  }
  long long r1 = 0, c1 = 0, r2 = R, c2 = C;
  long long dp[R][C];
  memset(dp, 0, sizeof(dp));
  for (i = r1; i < r2; i++) {
    for (j = c1; j < c2; j++) {
      if (i == r2 - 1 && j == c2 - 1) {
      }
      if (i == r2 - 1 && a[i][j] == '.') {
        if (j < c2 - 1 && a[i][j + 1] == '.') dp[i][j]++;
      } else if (j == c2 - 1 && a[i][j] == '.') {
        if (i < r2 - 1 && a[i + 1][j] == '.') dp[i][j]++;
      } else if (a[i][j] == '.') {
        if (j < c2 - 1 && a[i][j + 1] == '.') dp[i][j]++;
        if (i < r2 - 1 && a[i + 1][j] == '.') dp[i][j]++;
      }
      if (i > 0) dp[i][j] += dp[i - 1][j];
      if (j > 0) dp[i][j] += dp[i][j - 1];
      if (i > 0 && j > 0) dp[i][j] -= dp[i - 1][j - 1];
    }
  }
  cin >> q;
  while (q--) {
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    c1--;
    c2--;
    r2--;
    long long ans = 0;
    ans += dp[r2][c2];
    if (r1 > 0) ans -= dp[r1 - 1][c2];
    if (c1 > 0) ans -= dp[r2][c1 - 1];
    if (c1 > 0 && r1 > 0) ans += dp[r1 - 1][c1 - 1];
    for (i = r1; i < r2; i++) {
      if (a[i][c2] == '.') {
        if (c2 < C - 1 && a[i][c2 + 1] == '.') ans -= 1;
      }
    }
    for (i = c1; i < c2; i++) {
      if (a[r2][i] == '.') {
        if (r2 < R - 1 && a[r2 + 1][i] == '.') ans -= 1;
      }
    }
    if (a[r2][c2] == '.' && c2 < C - 1 && a[r2][c2 + 1] == '.') ans -= 1;
    if (a[r2][c2] == '.' && r2 < R - 1 && a[r2 + 1][c2] == '.') ans -= 1;
    cout << ans << "\n";
  }
  return 0;
}
