#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int h, w;
int q;
string s[510];
int hor[510][510];
int ver[510][510];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> h >> w;
  for (int(i) = 1; (i) <= (h); (i)++) {
    cin >> s[i];
    s[i] = " " + s[i];
  }
  cin >> q;
  for (int(i) = 1; (i) <= (h); (i)++) {
    int cur = 0;
    for (int j = 2; j <= w; j++) {
      if (s[i][j] == '.' && s[i][j - 1] == '.') {
        cur++;
      }
      hor[i][j] = cur;
    }
  }
  for (int(j) = 1; (j) <= (w); (j)++) {
    int cur = 0;
    for (int i = 2; i <= h; i++) {
      if (s[i][j] == '.' && s[i - 1][j] == '.') {
        cur++;
      }
      ver[j][i] = cur;
    }
  }
  for (int(hello) = 0; (hello) < (q); (hello)++) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long ans = 0;
    for (int i = r1; i <= r2; i++) {
      ans += hor[i][c2] - hor[i][c1 - 1];
      if (s[i][c1] == '.' && s[i][c1 - 1] == '.' && c1 > 1) {
        ans--;
      }
    }
    for (int j = c1; j <= c2; j++) {
      ans += ver[j][r2] - ver[j][r1 - 1];
      if (s[r1][j] == '.' && s[r1 - 1][j] == '.' && r1 > 1) {
        ans--;
      }
    }
    cout << ans << '\n';
  }
}
