#include <bits/stdc++.h>
using namespace std;
int dp[501][501], dp1[501][501];
int main() {
  int r, c;
  cin >> r >> c;
  string s[r + 10];
  for (int i = 0; i < r; i++) cin >> s[i];
  for (int i = 0; i < r; i++) {
    for (int j = 1; j < c; j++) {
      dp[i][j] = dp[i][j - 1] + (s[i][j] == '.' && s[i][j - 1] == '.');
    }
  }
  for (int i = 0; i < c; i++) {
    for (int j = 1; j < r; j++) {
      dp1[j][i] = dp1[j - 1][i] + (s[j][i] == '.' && s[j - 1][i] == '.');
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--, c1--, r2--, c2--;
    int sum = 0;
    for (int i = r1; i <= r2; i++) sum += dp[i][c2] - dp[i][c1];
    for (int i = c1; i <= c2; i++) sum += dp1[r2][i] - dp1[r1][i];
    cout << sum << endl;
  }
  return 0;
}
