#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M;
  cin >> N >> M;
  int memoHor[N + 1][M + 1];
  int memoVer[N + 1][M + 1];
  char Grid[N][M];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      memoHor[i][j] = 0;
      memoVer[i][j] = 0;
      cin >> Grid[i][j];
    }
  }
  for (int i = 0; i < N + 1; i++) {
    memoHor[i][M] = 0;
    memoVer[i][M] = 0;
  }
  for (int i = 0; i < M + 1; i++) {
    memoHor[N][i] = 0;
    memoVer[N][i] = 0;
  }
  for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < M + 1; j++) {
      if (Grid[i - 1][j - 1] == '.' && Grid[i - 1][j - 2] == '.') {
        memoVer[i][j] += memoVer[i][j - 1] + 1;
      } else {
        memoVer[i][j] = memoVer[i][j - 1];
      }
    }
  }
  for (int j = 1; j < M + 1; j++) {
    for (int i = 1; i < N + 1; i++) {
      if (Grid[i - 1][j - 1] == '.' && Grid[i - 2][j - 1] == '.') {
        memoHor[i][j] += memoHor[i - 1][j] + 1;
      } else {
        memoHor[i][j] = memoHor[i - 1][j];
      }
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int r1, l1, r2, l2;
    cin >> r1 >> l1 >> r2 >> l2;
    int sum = 0;
    for (int j = r1; j <= r2; j++) {
      sum += (memoVer[j][l2] - memoVer[j][l1]);
    }
    for (int j = l1; j <= l2; j++) {
      sum += (memoHor[r2][j] - memoHor[r1][j]);
    }
    cout << sum << endl;
  }
  return 0;
}
