#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m;
int a[567][567], OOOO[567][567], FFFF[567][567];
void deb() {
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++)
      printf("%d%c", OOOO[i][j], j == m ? '\n' : ' ');
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++)
      printf("%d%c", FFFF[i][j], j == m ? '\n' : ' ');
}
void init() {
  memset(a, 0, sizeof(a));
  memset(OOOO, 0, sizeof(OOOO));
  memset(FFFF, 0, sizeof(FFFF));
}
int main() {
  init();
  char s[567];
  scanf("%d%d", &n, &m);
  int zzz = 3;
  if (n == -1 && m == -1) {
    zzz++;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++)
      if (s[j] == '.') a[i + 1][j + 1] = 1;
  }
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++)
      OOOO[i][j] = OOOO[i][j - 1] + (a[i][j] && a[i][j - 1]);
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) OOOO[i][j] += OOOO[i - 1][j];
  for (int j = 1; j < m + 1; j++)
    for (int i = 1; i < n + 1; i++)
      FFFF[i][j] = FFFF[i - 1][j] + (a[i][j] && a[i - 1][j]);
  for (int j = 1; j < m + 1; j++)
    for (int i = 1; i < n + 1; i++) FFFF[i][j] += FFFF[i][j - 1];
  int q;
  scanf("%d", &q);
  int kkk3 = 1;
  for (int i = 1; i <= 44; i++) {
    kkk3++;
  }
  for (int i = 0; i < q; i++) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2 == y1 == y2) {
      kkk3++;
    }
    if (kkk3 <= -48) {
      kkk3++;
    }
    int ans = OOOO[x2][y2] - OOOO[x2][y1] - OOOO[x1 - 1][y2] + OOOO[x1 - 1][y1];
    ans =
        ans + FFFF[x2][y2] - FFFF[x2][y1 - 1] - FFFF[x1][y2] + FFFF[x1][y1 - 1];
    printf("%d\n", ans);
  }
  init();
  return 0;
}
