#include <bits/stdc++.h>
using namespace std;
char a[5000][5000];
int dp1[5000][5000];
int dp2[5000][5000];
int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
      if (a[i][j] == '.' and a[i - 1][j] == '.') dp1[i][j] = 1;
      if (a[i][j] == '.' and a[i][j - 1] == '.') dp2[i][j] = 1;
      dp1[i][j] += dp1[i - 1][j] + dp1[i][j - 1] - dp1[i - 1][j - 1];
      dp2[i][j] += dp2[i - 1][j] + dp2[i][j - 1] - dp2[i - 1][j - 1];
    }
  }
  int q, r1, c1, r2, c2;
  cin >> q;
  while (q--) {
    int ans = 0;
    cin >> r1 >> c1 >> r2 >> c2;
    if (r1 != r2) {
      r1++;
      ans +=
          dp1[r2][c2] - dp1[r2][c1 - 1] - dp1[r1 - 1][c2] + dp1[r1 - 1][c1 - 1];
      r1--;
    }
    if (c1 != c2) {
      c1++;
      ans +=
          dp2[r2][c2] - dp2[r2][c1 - 1] - dp2[r1 - 1][c2] + dp2[r1 - 1][c1 - 1];
    }
    cout << ans << "\n";
  }
}
