#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  for (long long j = 0; j < t; j++) {
    long long n, m;
    cin >> n >> m;
    vector<vector<char>> M(n + 1, vector<char>(m + 1, 'X'));
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        cin >> M[i][j];
      }
    }
    vector<vector<long long>> a(n + 1, vector<long long>(m + 1, 0));
    vector<vector<long long>> b(n + 1, vector<long long>(m + 1, 0));
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= m; j++) {
        if (M[i][j] == '.' && M[i][j - 1] == '.') a[i][j]++;
        if (M[i][j] == '.' && M[i - 1][j] == '.') b[i][j]++;
        a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
        b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
      }
    }
    long long q;
    cin >> q;
    for (long long p = 0; p < q; p++) {
      long long r1, c1, r2, c2;
      cin >> r1 >> c1 >> r2 >> c2;
      long long ans = 0;
      ans += a[r2][c2] + a[r1 - 1][c1] - a[r2][c1] - a[r1 - 1][c2];
      ans += b[r2][c2] + b[r1][c1 - 1] - b[r1][c2] - b[r2][c1 - 1];
      cout << ans << "\n";
    }
  }
  return 0;
}
