#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (!y) return x;
  return gcd(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char c[n + 1][m + 1];
    int h[n + 1][m + 1];
    int v[n + 1][m + 1];
    int dp1[n + 1][m + 1];
    int dp2[n + 1][m + 1];
    for (int i = 1; i <= n; i++) c[i][0] = '#';
    for (int i = 1; i <= m; i++) c[0][i] = '#';
    memset(h, 0, sizeof(h));
    memset(v, 0, sizeof(v));
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> c[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      int cnt = 0;
      for (int j = 1; j <= m; j++) {
        if ((c[i][j - 1] == '.') && (c[i][j] == '.')) {
          cnt++;
          h[i][j] = cnt;
        } else
          h[i][j] = h[i][j - 1];
      }
    }
    for (int i = 1; i <= m; i++) {
      int cnt = 0;
      for (int j = 1; j <= n; j++) {
        if (c[j - 1][i] != '#' && c[j][i] != '#') {
          cnt++;
          v[j][i] = cnt;
        } else
          v[j][i] = v[j - 1][i];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        dp1[i][j] = dp1[i - 1][j] + h[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        dp2[i][j] = dp2[i][j - 1] + v[i][j];
      }
    }
    int q;
    cin >> q;
    while (q--) {
      int a, b, c, d;
      int ans = 0;
      cin >> a >> b >> c >> d;
      if (c - a >= 1)
        ans += (dp2[c][d] - dp2[a][d] - dp2[c][b - 1] + dp2[a][b - 1]);
      if ((d - b) >= 1)
        ans += (dp1[c][d] - dp1[c][b] - dp1[a - 1][d] + dp1[a - 1][b]);
      cout << ans << endl;
    }
  }
  return 0;
}
