#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
string s[maxn];
int r[maxn][maxn], c[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 1; j < m; j++) {
      r[i][j] = r[i][j - 1] + (s[i][j] == '.' && s[i][j - 1] == '.');
    }
  for (int j = 0; j < m; j++)
    for (int i = 1; i < n; i++) {
      c[i][j] = c[i - 1][j] + (s[i][j] == '.' && s[i - 1][j] == '.');
    }
  int q;
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    x2--;
    y1--;
    y2--;
    int ans = 0;
    for (int i = y1; i <= y2; i++) ans += c[x2][i] - c[x1][i];
    for (int i = x1; i <= x2; i++) ans += r[i][y2] - r[i][y1];
    cout << ans << "\n";
  }
}
