#include <bits/stdc++.h>
using namespace std;
char a[555][555];
long long n, m, i, dp[555][555], j, aa, b, x, y, hor[555][555], ver[555][555];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      cin >> a[i][j];
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      ver[i][j] = ver[i - 1][j] + ver[i][j - 1] - ver[i - 1][j - 1];
      hor[i][j] = hor[i - 1][j] + hor[i][j - 1] - hor[i - 1][j - 1];
      if (a[i][j] == '.') {
        if (a[i - 1][j] == '.') dp[i][j]++, ver[i][j]++;
        if (a[i][j - 1] == '.') dp[i][j]++, hor[i][j]++;
      }
    }
  }
  cin >> m;
  for (i = 1; i <= m; ++i) {
    cin >> aa >> b >> x >> y;
    long long h, v;
    h = hor[x][b] - hor[x][b - 1] - hor[aa - 1][b] + hor[aa - 1][b - 1];
    v = ver[aa][y] - ver[aa - 1][y] - ver[aa][b - 1] + ver[aa - 1][b - 1];
    cout << dp[x][y] - dp[x][b - 1] - dp[aa - 1][y] + dp[aa - 1][b - 1] - h - v
         << '\n';
  }
  return false;
}
