#include <bits/stdc++.h>
using namespace std;
char s[505][505];
int cnt[505][505], num[505][505];
int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      for (int k = 1; k <= j - 1; k++) {
        if (s[i][k] == s[i][k + 1] && s[i][k] == '.') cnt[i][j]++;
      }
    }
  }
  for (int i = 1; i <= w; i++) {
    for (int j = 1; j <= h; j++) {
      for (int k = 1; k <= j - 1; k++) {
        if (s[k][i] == s[k + 1][i] && s[k][i] == '.') num[i][j]++;
      }
    }
  }
  while (q--) {
    int x, y, u, v;
    scanf("%d%d%d%d", &x, &y, &u, &v);
    int ans = 0;
    for (int i = x; i <= u; i++) ans += cnt[i][v] - cnt[i][y];
    for (int i = y; i <= v; i++) ans += num[i][u] - num[i][x];
    printf("%d\n", ans);
  }
  return 0;
}
