#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 502;
int a[maxn][maxn];
int izq[maxn][maxn], arr[maxn][maxn];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '.') a[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      izq[i][j] = izq[i][j - 1];
      if (a[i][j] && a[i][j - 1]) {
        izq[i][j]++;
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      arr[i][j] = arr[i - 1][j];
      if (a[i][j] && a[i - 1][j]) {
        arr[i][j]++;
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long int ans = 0;
    for (int f = r1; f <= r2; f++) {
      long long int res = izq[f][c2] - izq[f][c1 - 1];
      if (a[f][c1] && a[f][c1 - 1]) res--;
      ans += res;
    }
    for (int c = c1; c <= c2; c++) {
      long long int res = arr[r2][c] - arr[r1 - 1][c];
      if (a[r1][c] && a[r1 - 1][c]) res--;
      ans += res;
    }
    cout << ans << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
