#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long w, h, q, i, j, leftb, rightb, topb, bottomb;
  cin >> w >> h;
  char a[w][h];
  for (i = 0; i < w; i++) {
    for (j = 0; j < h; j++) {
      cin >> a[i][j];
    }
  }
  long long temp, ans, horizontal[w][h], vertical[w][h];
  memset(horizontal, 0, sizeof(horizontal));
  memset(vertical, 0, sizeof(vertical));
  for (i = 0; i < w; i++) {
    for (j = 1; j < h; j++) {
      if (a[i][j] == '.' && a[i][j - 1] == '.') {
        horizontal[i][j]++;
      }
      horizontal[i][j] += horizontal[i][j - 1];
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 1; j < w; j++) {
      horizontal[j][i] += horizontal[j - 1][i];
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 1; j < w; j++) {
      if (a[j][i] == '.' && a[j - 1][i] == '.') {
        vertical[j][i]++;
      }
      vertical[j][i] += vertical[j - 1][i];
    }
  }
  for (i = 0; i < w; i++) {
    for (j = 1; j < h; j++) {
      vertical[i][j] += vertical[i][j - 1];
    }
  }
  cin >> q;
  while (q--) {
    cin >> topb >> leftb >> bottomb >> rightb;
    topb--, leftb--, bottomb--, rightb--;
    ans = 0;
    temp = horizontal[bottomb][rightb] -
           (topb == 0 ? 0 : horizontal[topb - 1][rightb]);
    temp -= (horizontal[bottomb][leftb] -
             (topb == 0 ? 0 : horizontal[topb - 1][leftb]));
    ans += temp;
    temp = vertical[bottomb][rightb] -
           (leftb == 0 ? 0 : vertical[bottomb][leftb - 1]);
    temp -=
        (vertical[topb][rightb] - (leftb == 0 ? 0 : vertical[topb][leftb - 1]));
    ans += temp;
    cout << ans << "\n";
  }
  return 0;
}
