#include <bits/stdc++.h>
using namespace std;
const long int N = 1005;
long long n, m, i, j, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    string s[505];
    int r, c;
    cin >> r >> c;
    for (i = 0; i < r; i++) cin >> s[i];
    long long dp[r + 5][c + 5];
    dp[0][0] = 0;
    for (i = 1; i < r; i++)
      dp[i][0] = dp[i - 1][0] + (int)(s[i][0] == '.' && s[i - 1][0] == '.');
    for (i = 1; i < c; i++)
      dp[0][i] = dp[0][i - 1] + (int)(s[0][i] == '.' && s[0][i - 1] == '.');
    for (i = 1; i < r; i++) {
      for (j = 1; j < c; j++) {
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] +
                   (s[i][j] == '.') * 1LL *
                       ((int)(s[i][j - 1] == '.') + (int)(s[i - 1][j] == '.'));
      }
    }
    long q;
    cin >> q;
    while (q--) {
      int r1, r2, c2, c1;
      cin >> r1 >> c1 >> r2 >> c2;
      r1--, r2--, c1--, c2--;
      k = 0;
      for (i = r1; i <= r2; i++)
        if (c1 > 0)
          if (s[i][c1 - 1] == '.' && s[i][c1] == '.') k++;
      for (i = c1; i <= c2; i++)
        if (r1 > 0)
          if (s[r1 - 1][i] == '.' && s[r1][i] == '.') k++;
      long res = dp[r2][c2] + ((r1 > 0 && c1 > 0) ? dp[r1 - 1][c1 - 1] : 0) -
                 (((r1 > 0) ? dp[r1 - 1][c2] : 0) +
                  ((c1 > 0) ? dp[r2][c1 - 1] : 0) + k);
      cout << res << "\n";
    }
  }
  return 0;
}
