#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};
int X[6] = {0, 0, 0, -1, 0, 1};
int Y[6] = {0, 0, -1, 0, 1, 0};
int Z[6] = {1, -1, 0, 0, 0, 0};
long long gg[510][510];
char g[510][510];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
    }
  }
  memset(gg, 0, sizeof gg);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '.') {
        if (g[i][j + 1] == '.') {
          gg[i][j + 1]++;
        }
        if (g[i + 1][j] == '.') {
          gg[i + 1][j]++;
        }
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < n; j++) {
      gg[j][i] += gg[j - 1][i];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    r2--;
    c1--;
    c2--;
    long long ans = 0;
    for (int i = c1; i <= c2; i++) {
      if (r1 - 1 < 0)
        ans += gg[r2][i];
      else
        ans += (gg[r2][i] - gg[r1 - 1][i]);
      if (g[r1][i] == '.' && g[r1 - 1][i] == '.') ans--;
    }
    for (int i = r1; i <= r2; i++) {
      if (c1 - 1 < 0) continue;
      if (g[i][c1 - 1] == '.' && g[i][c1] == '.') ans--;
    }
    cout << ans << "\n";
  }
}
