#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int mcm(int a, int b) { return a * b / gcd(a, b); }
int sq(int a) { return a * a; }
int pot(int a, int b) { return b ? sq(pot(a, b >> 1)) * (b & 1 ? a : 1) : 1; }
char grid[505][505];
int gval[505][505];
int a, b;
int dp(int h, int w) {
  if (h < 0 || w < 0) return 0;
  if (gval[h][w] >= 0) return gval[h][w];
  if (h == 0 && w == 0) {
    gval[h][w] = 0;
  } else if (h == 0) {
    gval[h][w] = dp(h, w - 1) + (grid[h][w - 1] == '.' && grid[h][w] == '.');
  } else if (w == 0) {
    gval[h][w] = dp(h - 1, w) + (grid[h - 1][w] == '.' && grid[h][w] == '.');
  } else
    gval[h][w] =
        dp(h - 1, w) + dp(h, w - 1) - dp(h - 1, w - 1) +
        (grid[h][w] == '.' ? (grid[h - 1][w] == '.') + (grid[h][w - 1] == '.')
                           : 0);
  return gval[h][w];
}
int main() {
  memset(gval, -1, sizeof(gval));
  cin >> a >> b;
  for (int i = (0); i < a; i++)
    for (int j = (0); j < b; j++) cin >> grid[i][j];
  int q;
  cin >> q;
  for (int i = (0); i < q; i++) {
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--, c1--, c2--, r2--;
    if (r1 == r2 && c1 == c2)
      cout << 0 << endl;
    else {
      int res =
          dp(r2, c2) + dp(r1 - 1, c1 - 1) - dp(r2, c1 - 1) - dp(r1 - 1, c2);
      if (c1 > 0)
        for (int r = (r1); r < r2 + 1; r++)
          res -= (grid[r][c1 - 1] == '.' && grid[r][c1] == '.');
      if (r1 > 0)
        for (int c = (c1); c < c2 + 1; c++)
          res -= (grid[r1 - 1][c] == '.' && grid[r1][c] == '.');
      cout << res << endl;
    }
  }
}
