#include <bits/stdc++.h>
using namespace std;
bool prime[100005];
int dp[505][505], dp2[505][505];
int main() {
  long long int h, w, i, j, a, b, c, d, q, sum;
  cin >> h >> w;
  char arr[h][w + 1];
  for (i = 0; i <= h - 1; i++) cin >> arr[i];
  for (i = 0; i <= h - 1; i++) {
    for (j = 1; j <= w - 1; j++) {
      if (arr[i][j] == '.' && arr[i][j - 1] == '.')
        dp[i][j] = dp[i][j - 1] + 1;
      else
        dp[i][j] = dp[i][j - 1];
    }
  }
  for (i = 0; i <= w - 1; i++) {
    for (j = 1; j <= h - 1; j++) {
      if (arr[j][i] == '.' && arr[j - 1][i] == '.')
        dp2[j][i] = dp2[j - 1][i] + 1;
      else
        dp2[j][i] = dp2[j - 1][i];
    }
  }
  cin >> q;
  while (q--) {
    sum = 0;
    cin >> a >> b >> c >> d;
    for (i = a - 1; i <= c - 1; i++) sum = sum + dp[i][d - 1] - dp[i][b - 1];
    for (i = b - 1; i <= d - 1; i++) sum = sum + dp2[c - 1][i] - dp2[a - 1][i];
    cout << sum << endl;
  }
}
