#include <bits/stdc++.h>
using namespace std;
int h, w, q, a, b, c, d, f[507][507];
string s[507];
bool in(int x, int y) { return (x >= 1 && x <= h && y >= 1 && y <= w); }
int main() {
  cin >> h >> w;
  for (int i = 1; i <= h; i++) cin >> s[i], s[i] = "0" + s[i];
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      f[i][j] = 0;
      if (in(i - 1, j) && s[i][j] == '.' && s[i - 1][j] == '.') f[i][j]++;
      if (in(i, j - 1) && s[i][j] == '.' && s[i][j - 1] == '.') f[i][j]++;
      if (in(i - 1, j)) f[i][j] += f[i - 1][j];
      if (in(i, j - 1)) f[i][j] += f[i][j - 1];
      if (in(i - 1, j - 1)) f[i][j] -= f[i - 1][j - 1];
    }
  }
  cin >> q;
  while (q--) {
    cin >> a >> b >> c >> d;
    long long ans = f[c][d];
    if (in(a - 1, d)) ans -= f[a - 1][d];
    if (in(c, b - 1)) ans -= f[c][b - 1];
    if (in(a - 1, b - 1)) ans += f[a - 1][b - 1];
    for (int i = b; i <= d; i++) {
      if (in(a - 1, i) && s[a][i] == '.' && s[a - 1][i] == '.') ans--;
    }
    for (int i = a; i <= c; i++) {
      if (in(i, b - 1) && s[i][b] == '.' && s[i][b - 1] == '.') ans--;
    }
    cout << ans << endl;
  }
  return 0;
}
