#include <bits/stdc++.h>
using namespace std;
int h, w;
char s[505][505];
int num[505][505];
int A[505][505];
int B[505][505];
int main() {
  cin >> 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] == '.')
        num[i][j] = 1;
      else
        num[i][j] = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (num[i][j] && num[i][j + 1])
        A[i][j] = A[i][j - 1] + 1;
      else
        A[i][j] = A[i][j - 1];
    }
  }
  for (int i = 1; i <= w; i++) {
    for (int j = 1; j <= h; j++) {
      if (num[j][i] && num[j + 1][i])
        B[j][i] = B[j - 1][i] + 1;
      else
        B[j][i] = B[j - 1][i];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int ans = 0;
    for (int i = x1; i <= x2; i++) ans += A[i][y2 - 1] - A[i][y1 - 1];
    for (int i = y1; i <= y2; i++) ans += B[x2 - 1][i] - B[x1 - 1][i];
    printf("%d\n", ans);
  }
}
