#include <bits/stdc++.h>
using namespace std;
const int N = 501;
int n, m, q, dp[N][N], d[N][N];
char a[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == '.' && a[i][j - 1] == '.') d[i][j] = 1;
      if (a[i][j] == '.' && a[i - 1][j] == '.') dp[i][j] = 1;
      d[i][j] += d[i][j - 1];
      dp[i][j] += dp[i][j - 1];
    }
  }
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    int ans = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    for (int i = x1; i <= x2; i++) {
      if (i > x1) ans += (dp[i][y2] - dp[i][y1 - 1]);
      ans += (d[i][y2] - d[i][y1]);
    }
    cout << ans << endl;
  }
  return 0;
}
