#include <bits/stdc++.h>
using namespace std;
void IOS() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
int32_t main() {
  IOS();
  long long int row, col;
  cin >> row >> col;
  string s[row];
  for (long long int i = 0; i < row; i++) {
    cin >> s[i];
  }
  long long int dp[row][col + 1];
  memset(dp, 0, sizeof(dp));
  for (long long int i = 0; i < row; i++) {
    for (long long int j = 1; j <= col; j++) {
      long long int num = 0;
      if (s[i][j - 1] == '.') {
        if (i < row - 1 && s[i + 1][j - 1] == '.') {
          num++;
        }
        if (j < col && s[i][j] == '.') {
          num++;
        }
      }
      dp[i][j] = dp[i][j - 1] + num;
    }
  }
  long long int q;
  cin >> q;
  while (q--) {
    long long int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--, r2--;
    long long int sum = 0;
    if (r2 - r1 > 0 && c2 - c1 > 0) {
      for (long long int i = r1; i < r2; i++) {
        sum += dp[i][c2 - 1] - dp[i][c1 - 1];
      }
      for (long long int i = r1; i < r2; i++) {
        if (s[i][c2 - 1] == '.' && s[i + 1][c2 - 1] == '.') {
          sum++;
        }
      }
      for (long long int i = c1; i < c2; i++) {
        if (s[r2][i - 1] == '.' && s[r2][i] == '.') {
          sum++;
        }
      }
    } else if (c2 - c1 == 0) {
      for (long long int i = r1; i < r2; i++) {
        if (s[i][c2 - 1] == '.' && s[i + 1][c2 - 1] == '.') {
          sum++;
        }
      }
    } else {
      for (long long int i = c1; i < c2; i++) {
        if (s[r2][i - 1] == '.' && s[r2][i] == '.') {
          sum++;
        }
      }
    }
    cout << sum << endl;
  }
}
