#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void upd_max(T& dest, const T& src) {
  if (dest < src) dest = src;
  return;
}
template <typename T>
inline void upd_min(T& dest, const T& src) {
  if (dest > src) dest = src;
  return;
}
const int maxN = 500 + 13;
int h, w, q;
char s[maxN][maxN];
int f[maxN][maxN];
int g[maxN][maxN];
int sum1[maxN][maxN];
int sum2[maxN][maxN];
int main() {
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  memset(sum1, 0, sizeof(sum1));
  memset(sum2, 0, sizeof(sum2));
  scanf("%d%d", &h, &w);
  for (int i = 1; i <= h; i++) scanf("%s", &s[i][1]);
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (s[i][j] == '#') {
        sum1[i][j] = sum1[i][j - 1];
        sum2[i][j] = sum2[i - 1][j] + sum1[i][j];
        continue;
      }
      if (s[i - 1][j] == '.') f[i][j]++;
      if (s[i][j - 1] == '.') g[i][j]++;
      sum1[i][j] = sum1[i][j - 1] + f[i][j] + g[i][j];
      sum2[i][j] = sum2[i - 1][j] + sum1[i][j];
    }
  }
  scanf("%d", &q);
  int r1, c1, r2, c2;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    int ans = sum2[r2][c2];
    ans -= sum2[r2][c1 - 1];
    ans -= sum2[r1 - 1][c2];
    ans += sum2[r1 - 1][c1 - 1];
    for (int i = r1; i <= r2; i++)
      if (g[i][c1] == 1) ans--;
    for (int i = c1; i <= c2; i++)
      if (f[r1][i] == 1) ans--;
    cout << ans << endl;
  }
  return 0;
}
