#include <bits/stdc++.h>
using namespace std;
string t[501];
int main() {
  int a[501][501] = {0}, b[501][501] = {0};
  int w, h;
  cin >> h >> w;
  cin.ignore();
  for (int i = 0; i < h; i++) cin >> t[i];
  a[0][0] = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      a[i][j] = a[i][j - 1];
      if (t[i][j] == '.' && t[i][j - 1] == '.') a[i][j]++;
    }
  }
  b[0][0] = 0;
  for (int j = 0; j < w; j++) {
    for (int i = 1; i < h; i++) {
      b[i][j] = b[i - 1][j];
      if (t[i][j] == '.' && t[i - 1][j] == '.') b[i][j]++;
    }
  }
  int n;
  cin >> n;
  int x1, y1, x2, y2;
  for (int i = 0; i < n; i++) {
    int dem = 0;
    cin >> y1 >> x1 >> y2 >> x2;
    x1--;
    y1--;
    x2--;
    y2--;
    for (int i = y1; i <= y2; i++) dem += a[i][x2] - a[i][x1];
    for (int i = x1; i <= x2; i++) {
      dem += b[y2][i] - b[y1][i];
    }
    cout << dem << endl;
  }
}
