#include <bits/stdc++.h>
using namespace std;
char c[501][501];
int dp[501][501];
int h[501][501];
int v[501][501];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int l, w;
  cin >> l >> w;
  for (int i = 1; i <= l; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 1; i <= l; i++) {
    for (int j = 1; j <= w; j++) {
      v[i][j] = v[i - 1][j];
      h[i][j] = h[i][j - 1];
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      if (c[i][j] == '.' && c[i][j - 1] == '.') {
        dp[i][j]++;
        v[i][j]++;
      }
      if (c[i][j] == '.' && c[i - 1][j] == '.') {
        dp[i][j]++;
        h[i][j]++;
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int ans = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] +
              dp[x1 - 1][y1 - 1] - v[x2][y1] + v[x1 - 1][y1] - h[x1][y2] +
              h[x1][y1 - 1];
    cout << ans << "\n";
  }
}
