#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, ans, sum, dp[509][509], raoh[509][509], raov[509][509],
    k[509][509], q;
char c[509][509];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> c[i][j];
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (j < m) {
        if (c[i][j] == '.' && c[i][j + 1] == '.') {
          k[i][j + 1]++;
          raoh[i][j]++;
        }
      }
      if (i < n) {
        if (c[i][j] == '.' && c[i + 1][j] == '.') {
          k[i + 1][j]++;
          raov[i][j]++;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + k[i][j] - dp[i - 1][j - 1];
      raov[i][j] += raov[i][j - 1];
      raoh[i][j] += raoh[i - 1][j];
    }
  }
  cin >> q;
  while (q--) {
    long long a1, a2, b1, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    ans = dp[a2][b2] + dp[a1 - 1][b1 - 1] - dp[a2][b1 - 1] - dp[a1 - 1][b2];
    ans -= (raoh[a2][b1 - 1] - raoh[a1 - 1][b1 - 1]);
    ans -= (raov[a1 - 1][b2] - raov[a1 - 1][b1 - 1]);
    cout << ans << endl;
  }
  return 0;
}
