#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[510][510];
int da[510][510], db[510][510];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < m; j++) {
      da[i][j] = da[i][j - 1];
      if (s[i][j] == '.' && s[i][j + 1] == '.') da[i][j]++;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i < n; i++) {
      db[i][j] = db[i - 1][j];
      if (s[i][j] == '.' && s[i + 1][j] == '.') db[i][j]++;
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int ax, ay, bx, by;
    scanf("%d %d %d %d", &ax, &ay, &bx, &by);
    int ans = 0;
    for (int i = ax; i <= bx; i++) ans += da[i][by - 1] - da[i][ay - 1];
    for (int i = ay; i <= by; i++) ans += db[bx - 1][i] - db[ax - 1][i];
    printf("%d\n", ans);
  }
}
