#include <bits/stdc++.h>
using namespace std;
char grid[555][555];
long long dp[555][555];
long long calc(int u, int v) {
  if (u < 0 || v < 0) return 0;
  return dp[u][v];
}
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) scanf("%s", grid[i]);
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) {
      if (j == 0) {
        if (i == 0) continue;
        dp[i][j] = dp[i - 1][j];
        if (grid[i - 1][j] == '.' && grid[i][j] == '.') dp[i][j]++;
        continue;
      }
      dp[i][j] += dp[i][j - 1];
      for (int k = 0; k < i; k++) {
        if (grid[k][j - 1] == '.' && grid[k][j] == '.') dp[i][j]++;
        if (grid[k][j] == '.' && grid[k + 1][j] == '.') dp[i][j]++;
      }
      if (grid[i][j - 1] == '.' && grid[i][j] == '.') dp[i][j]++;
    }
  int q, x, y, xx, yy;
  cin >> q;
  while (q--) {
    scanf("%d%d%d%d", &x, &y, &xx, &yy);
    x -= 2, y -= 2, xx--, yy--;
    long long n = calc(xx, yy) - calc(x, yy) - calc(xx, y) + calc(x, y);
    for (int u = x + 1; u <= xx; u++) {
      if (y < 0) break;
      if (grid[u][y] == '.' && grid[u][y + 1] == '.') n--;
    }
    for (int v = y + 1; v <= yy; v++) {
      if (x < 0) break;
      if (grid[x][v] == '.' && grid[x + 1][v] == '.') n--;
    }
    cout << n << endl;
  }
  return 0;
}
