#include <bits/stdc++.h>
using namespace std;
char grid[501][501];
int dp[501][501], n, m;
bool isvalid(int i, int j) {
  if (i < 0 || i > n || j < 0 || j > m || grid[i][j] == '#') return 0;
  return 1;
}
int main() {
  int i, j, q, x1, y1, x2, y2, t;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) cin >> grid[i][j];
  }
  dp[0][0] = 0;
  for (i = 0; i <= n; i++) dp[i][0] = 0;
  for (j = 0; j <= m; j++) dp[0][j] = 0;
  for (j = 2; j <= m; j++) {
    if (isvalid(1, j) && isvalid(1, j - 1))
      dp[1][j] = 1 + dp[1][j - 1];
    else
      dp[1][j] = dp[1][j - 1];
  }
  for (i = 2; i <= n; i++) {
    if (isvalid(i, 1) && isvalid(i - 1, 1))
      dp[i][1] = 1 + dp[i - 1][1];
    else
      dp[i][1] = dp[i - 1][1];
  }
  for (i = 2; i <= n; i++) {
    for (j = 2; j <= m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      if (isvalid(i, j) && isvalid(i - 1, j)) dp[i][j]++;
      if (isvalid(i, j) && isvalid(i, j - 1)) dp[i][j]++;
    }
  }
  cin >> q;
  while (q--) {
    cin >> x1 >> y1 >> x2 >> y2;
    t = dp[x2][y1 - 1] + dp[x1 - 1][y2] - dp[x1 - 1][y1 - 1];
    if (y1 > 1) {
      for (i = x1; i <= x2; i++) {
        if (grid[i][y1] == '.' && grid[i][y1 - 1] == '.') t++;
      }
    }
    if (x1 > 1) {
      for (j = y1; j <= y2; j++) {
        if (grid[x1][j] == '.' && grid[x1 - 1][j] == '.') t++;
      }
    }
    cout << dp[x2][y2] - t << endl;
  }
  return 0;
}
