#include <bits/stdc++.h>
using namespace std;
int h, w;
int a[500][500];
char mp[500][500];
int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) scanf("%s", mp[i]);
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (i + 1 < h && mp[i][j] == '.' && mp[i + 1][j] == '.') a[i][j]++;
      if (j + 1 < w && mp[i][j] == '.' && mp[i][j + 1] == '.') a[i][j]++;
    }
  for (int i = 0; i < h; ++i)
    for (int j = 1; j < w; ++j) {
      a[i][j] += a[i][j - 1];
    }
  int q;
  scanf("%d", &q);
  int x1, y1, x2, y2;
  while (q--) {
    scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
    x1--;
    y1--;
    x2--;
    y2--;
    int ans = 0;
    for (int i = y1; i <= y2; ++i) {
      if (x1 - 1 >= 0) ans -= a[i][x1 - 1];
      ans += a[i][x2];
      if (x2 + 1 < w && mp[i][x2] == '.' && mp[i][x2 + 1] == '.') ans--;
    }
    for (int i = x1; i <= x2; ++i)
      if (y2 + 1 < h && mp[y2][i] == '.' && mp[y2 + 1][i] == '.') ans--;
    printf("%d\n", ans);
  }
}
