#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e2 + 20;
char s[maxn][maxn];
int Rt[maxn][maxn], Ct[maxn][maxn];
void init(int h, int w) {
  for (int i = 1; i <= h; ++i) {
    Rt[i][0] = 0;
    Rt[i][1] = 0;
    for (int j = 2; j <= w; ++j) {
      Rt[i][j] = Rt[i][j - 1];
      Rt[i][j] += (s[i][j] == '.' && s[i][j - 1] == '.');
    }
  }
  for (int i = 1; i <= w; ++i) {
    Ct[i][0] = Ct[i][1] = 0;
    for (int j = 2; j <= h; ++j) {
      Ct[i][j] = Ct[i][j - 1];
      Ct[i][j] += (s[j - 1][i] == '.' && s[j][i] == '.');
    }
  }
}
int main() {
  int h, w;
  while (scanf("%d%d", &h, &w) == 2) {
    memset(s, '#', sizeof s);
    for (int i = 1; i <= h; ++i) scanf("%s", s[i] + 1);
    init(h, w);
    int Q;
    scanf("%d", &Q);
    while (Q--) {
      int x, y, a, b;
      scanf("%d%d%d%d", &x, &y, &a, &b);
      long long ans = 0;
      for (int i = x; i <= a; ++i) ans += Rt[i][b] - Rt[i][y];
      for (int i = y; i <= b; ++i) ans += Ct[i][a] - Ct[i][x];
      cout << ans << endl;
    }
  }
  return 0;
}
