#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  int q;
  cin >> q;
  int dp1[h][w];
  int dp2[h][w];
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if (v[i][j] == '.' && v[i][j - 1] == '.') {
        dp1[i][j] = dp1[i][j - 1] + 1;
      } else {
        dp1[i][j] = dp1[i][j - 1];
      }
    }
  }
  for (int i = 1; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v[i][j] == '.' && v[i - 1][j] == '.') {
        dp2[i][j] = dp2[i - 1][j] + 1;
      } else {
        dp2[i][j] = dp2[i - 1][j];
      }
    }
  }
  while (q--) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    r2--;
    c1--;
    c2--;
    int ans = 0;
    for (int i = r1; i <= r2; i++) {
      ans += (dp1[i][c2] - dp1[i][c1]);
    }
    for (int i = c1; i <= c2; i++) {
      ans += (dp2[r2][i] - dp2[r1][i]);
    }
    cout << ans << "\n";
  }
}
