#include <bits/stdc++.h>
using namespace std;
int w, h, q;
const int mxN = 505;
vector<string> grid(mxN);
vector<vector<int> > Horizontal(mxN, vector<int>(mxN));
vector<vector<int> > Vertical(mxN, vector<int>(mxN));
int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      Horizontal[j + 1][i + 1] =
          Horizontal[j][i + 1] + Horizontal[j + 1][i] - Horizontal[j][i];
      Vertical[j + 1][i + 1] =
          Vertical[j][i + 1] + Vertical[j + 1][i] - Vertical[j][i];
      if (grid[i][j] != '.') {
        continue;
      }
      if (j != w - 1 && grid[i][j + 1] == '.') {
        ++Horizontal[j + 1][i + 1];
      }
      if (i != h - 1 && grid[i + 1][j] == '.') {
        ++Vertical[j + 1][i + 1];
      }
    }
  }
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    --x1, --y1;
    int answer = 0;
    answer += Horizontal[x2 - 1][y2] - Horizontal[x1][y2] -
              Horizontal[x2 - 1][y1] + Horizontal[x1][y1];
    answer += Vertical[x2][y2 - 1] - Vertical[x1][y2 - 1] - Vertical[x2][y1] +
              Vertical[x1][y1];
    cout << answer << "\n";
  }
  return 0;
}
