#include <bits/stdc++.h>
using namespace std;
int dpdoc[503][503];
int dpngang[503][503];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int h, w;
  cin >> h >> w;
  char a[503][503];
  for (int i = 0; i <= w + 1; i++) {
    a[0][i] = '#';
    a[h + 1][i] = '#';
  }
  for (int i = 0; i <= h + 1; i++) {
    a[i][0] = '#';
    a[i][w + 1] = '#';
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      dpngang[i][j] =
          dpngang[i - 1][j] + dpngang[i][j - 1] - dpngang[i - 1][j - 1];
      dpdoc[i][j] = dpdoc[i - 1][j] + dpdoc[i][j - 1] - dpdoc[i - 1][j - 1];
      if (a[i][j] == '.') {
        if (a[i - 1][j] == '.') {
          dpngang[i][j]++;
        }
        if (a[i][j - 1] == '.') {
          dpdoc[i][j]++;
        }
      }
    }
  }
  int q;
  cin >> q;
  int r1, c1, r2, c2;
  while (q--) {
    cin >> r1 >> c1 >> r2 >> c2;
    int ans = 0;
    ans += dpngang[r2][c2] - dpngang[r2][c1 - 1] - dpngang[r1][c2] +
           dpngang[r1][c1 - 1];
    ans +=
        dpdoc[r2][c2] - dpdoc[r2][c1] - dpdoc[r1 - 1][c2] + dpdoc[r1 - 1][c1];
    cout << ans << "\n";
  }
  return 0;
}
