#include <bits/stdc++.h>
using namespace std;
int a[567][567], b[567][567];
int main() {
  int n, m, i, j, k, l;
  int h, w, cnt;
  char s[567][567];
  cin >> h >> w;
  for (i = 0; i < h; i++) scanf("%s", s[i]);
  for (i = 0; i < h; i++)
    for (j = cnt = 0; j < w; j++)
      if (s[i][j] == '.')
        cnt++, a[i + 1][j + 1] += a[i + 1][j],
            a[i + 1][j + 1] += (cnt >= 2) ? 1 : 0;
      else
        a[i + 1][j + 1] = a[i + 1][j], cnt = 0;
  for (j = 0; j < w; j++)
    for (i = cnt = 0; i < h; i++)
      if (s[i][j] == '.')
        cnt++, b[i + 1][j + 1] += b[i][j + 1],
            b[i + 1][j + 1] += (cnt >= 2) ? 1 : 0;
      else
        b[i + 1][j + 1] = b[i][j + 1], cnt = 0;
  int q;
  cin >> q;
  while (q--) {
    int ans = 0, r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    for (i = r1; i <= r2; i++) ans += (a[i][c2] - a[i][c1]);
    for (i = c1; i <= c2; i++) ans += (b[r2][i] - b[r1][i]);
    cout << ans << '\n';
  }
  return 0;
}
