#include <bits/stdc++.h>
using namespace std;
int h, w;
char g[510][510];
int s[510][510];
int main() {
  cin >> h >> w;
  for (int i = 1; i <= h; i++) scanf("\n%s", g[i] + 1);
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) {
      s[i][j] = s[i][j - 1];
      for (int k = i; k >= 1; k--) {
        if (g[k][j] == '.' && j > 1 && g[k][j - 1] == '.') s[i][j]++;
        if (g[k][j] == '.' && k > 1 && g[k - 1][j] == '.') s[i][j]++;
      }
    }
  int q;
  cin >> q;
  while (q--) {
    int r1, c1, r2, c2;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    int ans = s[r2][c2] - s[r1 - 1][c2] - s[r2][c1 - 1] + s[r1 - 1][c1 - 1];
    for (int i = r1; i <= r2; i++)
      if (g[i][c1] == '.' && c1 > 1 && g[i][c1 - 1] == '.') ans--;
    for (int i = c1; i <= c2; i++)
      if (g[r1][i] == '.' && r1 > 1 && g[r1 - 1][i] == '.') ans--;
    printf("%d\n", ans);
  }
  return 0;
}
