#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <typename T>
inline void scaf(T& v) {
  char ch = getchar();
  int sgn = 1;
  for (; '-' != ch && (ch < '0' || ch > '9'); ch = getchar())
    ;
  if ('-' == ch)
    sgn = -1, v = 0;
  else
    v = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    v = (v << 1) + (v << 3) + ch - '0';
  v *= sgn;
}
const int maxN = 1e5 + 10;
typedef int iArray[maxN];
typedef char cArray[maxN];
const int magic = 31;
const long long mod = 1e9 + 7;
char mat[555][555];
long long dp[555][555][2];
long long sum[555][555][2];
long long finalSum[555][555];
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", mat[i] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j][0] =
          dp[i][j - 1][0] + (mat[i][j] == '.' && mat[i][j - 1] == '.');
      dp[i][j][1] =
          dp[i - 1][j][1] + (mat[i][j] == '.' && mat[i - 1][j] == '.');
      sum[i][j][0] = dp[i][j][0] + sum[i - 1][j][0];
      sum[i][j][1] = dp[i][j][1] + sum[i][j - 1][1];
      finalSum[i][j] = sum[i][j][0] + sum[i][j][1];
    }
  }
  int q;
  int l, r, ll, rr;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d%d", &l, &r, &ll, &rr);
    int iCnt = 0;
    for (i = l; i <= ll; ++i) {
      iCnt += mat[i][r - 1] == '.' && mat[i][r] == '.';
    }
    for (i = r; i <= rr; ++i) {
      iCnt += mat[l][i] == '.' && mat[l - 1][i] == '.';
    }
    std::cout << finalSum[ll][rr] - finalSum[l - 1][rr] - finalSum[ll][r - 1] +
                     finalSum[l - 1][r - 1] - iCnt
              << std::endl;
  }
  return 0;
}
