#include <bits/stdc++.h>
using namespace std;
const int MAX = 2005;
int H[MAX][MAX], V[MAX][MAX];
char s[MAX][MAX];
int main() {
  int w, h;
  cin >> h >> w;
  for (int y = 0; y < h; y++) cin >> s[y];
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) {
      H[x + 1][y + 1] = H[x][y + 1] + H[x + 1][y] - H[x][y];
      V[x + 1][y + 1] = V[x][y + 1] + V[x + 1][y] - V[x][y];
      if (s[y][x] != '.') continue;
      if (x != w - 1 && s[y][x + 1] == '.') H[x + 1][y + 1]++;
      if (y != h - 1 && s[y + 1][x] == '.') V[x + 1][y + 1]++;
    }
  int q;
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    --x1, --y1;
    int ans = 0;
    ans += H[x2 - 1][y2] - H[x1][y2] - H[x2 - 1][y1] + H[x1][y1];
    ans += V[x2][y2 - 1] - V[x1][y2 - 1] - V[x2][y1] + V[x1][y1];
    cout << ans << "\n";
  }
  return 0;
}
