#include <bits/stdc++.h>
using namespace std;
int h, w, x, r1, r2, c1, c2, ans;
int A[501][501];
int B[501][501];
long long p;
char ch;
int main() {
  scanf("%d %d", &h, &w);
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> ch;
      if (ch == '.') {
        A[i][j] = 1;
      } else {
        A[i][j] = 0;
      }
    }
  }
  p = 0;
  for (int i = 2; i <= h; i++) {
    if ((A[i][1] == 1) and (A[i - 1][1] == 1)) {
      p++;
      B[i][1] = p;
    } else {
      B[i][1] = B[i - 1][1];
    }
  }
  p = 0;
  for (int i = 2; i <= w; i++) {
    if ((A[1][i] == 1) and (A[1][i - 1] == 1)) {
      p++;
      B[1][i] = p;
    } else {
      B[1][i] = B[1][i - 1];
    }
  }
  for (int i = 2; i <= h; i++) {
    p = 0;
    for (int j = 2; j <= w; j++) {
      B[i][j] = B[i][j - 1];
      for (int ii = 1; ii <= i; ii++) {
        if ((A[ii][j] == 1) and (A[ii][j - 1] == 1)) {
          B[i][j]++;
        }
        if ((A[ii][j] == 1) and (A[ii + 1][j] == 1) and (ii < i)) {
          B[i][j]++;
        }
      }
    }
  }
  scanf("%d", &x);
  for (int i = 0; i < x; i++) {
    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    if ((r1 == r2) and (c1 == c2)) {
      printf("%d \n", 0);
    } else {
      ans = B[r2][c2] - B[r2][c1 - 1] - B[r1 - 1][c2] + B[r1 - 1][c1 - 1];
      for (int ii = r1; ii <= r2; ii++) {
        if ((A[ii][c1] == 1) and (A[ii][c1 - 1] == 1)) {
          ans--;
        }
      }
      for (int ii = c1; ii <= c2; ii++) {
        if ((A[r1][ii] == 1) and (A[r1 - 1][ii] == 1)) {
          ans--;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
