#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, q;
  cin >> n >> m;
  char table[n + 1][m + 1];
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> table[i][j];
    }
  }
  long long dp[n + 1][m + 1];
  dp[1][1] = 0;
  for (long long i = 2; i <= n; i++) {
    dp[i][1] = dp[i - 1][1];
    if (table[i][1] == '.' and table[i - 1][1] == '.') dp[i][1]++;
  }
  for (long long i = 2; i <= m; i++) {
    dp[1][i] = dp[1][i - 1];
    if (table[1][i] == '.' and table[1][i - 1] == '.') dp[1][i]++;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = 2; j <= m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      if (table[i][j] == '.' and table[i - 1][j] == '.') dp[i][j]++;
      if (table[i][j] == '.' and table[i][j - 1] == '.') dp[i][j]++;
    }
  }
  cin >> q;
  long long ans[q];
  for (long long i = 0; i < q; i++) {
    long long c1, r1, c2, r2;
    cin >> r1 >> c1 >> r2 >> c2;
    ans[i] = dp[r2][c2];
    if (r1 > 1) ans[i] -= dp[r1 - 1][c2];
    if (c1 > 1) ans[i] -= dp[r2][c1 - 1];
    if (c1 > 1 and r1 > 1) ans[i] += dp[r1 - 1][c1 - 1];
    if (r1 > 1)
      for (long long j = c1; j <= c2; j++)
        if (table[r1][j] == '.' and table[r1 - 1][j] == '.') ans[i]--;
    if (c1 > 1)
      for (long long j = r1; j <= r2; j++)
        if (table[j][c1] == '.' and table[j][c1 - 1] == '.') ans[i]--;
  }
  for (long long i = 0; i < q; i++) cout << ans[i] << "\n";
}
