#include <bits/stdc++.h>
using namespace std;
int dp1[505][505], dp2[505][505], grid[505][505];
int main() {
  int h, w, i, j;
  cin >> h >> w;
  for (i = 1; i <= h; i++) {
    string get;
    cin >> get;
    for (j = 1; j <= w; j++) {
      if (get[j - 1] == '.') {
        grid[i][j] = 1;
      } else {
        grid[i][j] = 0;
      }
    }
  }
  for (i = 1; i <= h; i++) {
    for (j = 1; j <= w; j++) {
      if (grid[i][j] == 1 && grid[i - 1][j] == 1) {
        dp1[i][j]++;
      }
      if (grid[i][j] == 1 && grid[i][j - 1] == 1) {
        dp2[i][j]++;
      }
      dp1[i][j] += (dp1[i - 1][j] + dp1[i][j - 1] - dp1[i - 1][j - 1]);
      dp2[i][j] += (dp2[i - 1][j] + dp2[i][j - 1] - dp2[i - 1][j - 1]);
    }
  }
  int q, r1, c1, r2, c2;
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> r1 >> c1 >> r2 >> c2;
    int ret = 0;
    ret += (dp1[r2][c2] - dp1[r1][c2] - dp1[r2][c1 - 1] + dp1[r1][c1 - 1]);
    ret += (dp2[r2][c2] - dp2[r1 - 1][c2] - dp2[r2][c1] + dp2[r1 - 1][c1]);
    cout << ret << endl;
  }
  return 0;
}
