#include <bits/stdc++.h>
using namespace std;
int dp[510][510][2];
char ch[510][510];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> ch[i] + 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dp[i][j][1] = dp[i - 1][j][1] + dp[i][j - 1][1] - dp[i - 1][j - 1][1];
      if (ch[i][j] == '.') {
        if (i > 1 && ch[i - 1][j] == '.') dp[i][j][1]++;
        if (j > 1 && ch[i][j - 1] == '.') dp[i][j][1]++;
      }
    }
  int ans = 0;
  int q, a, b, c, d;
  cin >> q;
  while (q--) {
    cin >> a >> b >> c >> d;
    int ans = dp[c][d][1] - dp[a][d][1] - dp[c][b][1] + dp[a][b][1];
    for (int i = a; i < c; i++)
      if (ch[i][b] == '.' && ch[i + 1][b] == '.') ans++;
    for (int i = b; i < d; i++)
      if (ch[a][i] == '.' && ch[a][i + 1] == '.') ans++;
    printf("%d\n", ans);
  }
  return 0;
}
