#include <bits/stdc++.h>
using namespace std;
const int mx = 5e2 + 7;
char a[mx][mx];
int dp[mx][mx];
int main() {
  int max1 = -1e8 - 1;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1];
      if (a[i][j] == '.' && a[i][j - 1] == '.') dp[i][j]++;
      if (a[i][j] == '.' && a[i - 1][j] == '.') dp[i][j]++;
    }
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int r, l, r1, l1;
    cin >> r >> l >> r1 >> l1;
    if (r == r1 && l == l1) {
      cout << 0 << '\n';
    } else {
      int ans = 0;
      for (int j = l; j <= l1; j++)
        if (a[r][j] == '.' && a[r - 1][j] == '.') ans++;
      for (int j = r; j <= r1; j++)
        if (a[j][l] == '.' && a[j][l - 1] == '.') ans++;
      cout << dp[r1][l1] - dp[r1][l - 1] - dp[r - 1][l1] + dp[r - 1][l - 1] -
                  ans
           << '\n';
    }
  }
}
