#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int h, w;
bool arr[500 + 1][500 + 1];
int hor[500 + 1][500 + 1], ver[500 + 1][500 + 1];
int d(int x, int y) { return hor[x][y] + ver[x][y]; }
int get_hor(int x1, int y1, int x2, int y2) {
  return hor[x2][y2] - hor[x2][y1] - hor[x1 - 1][y2] + hor[x1 - 1][y1];
}
int get_ver(int x1, int y1, int x2, int y2) {
  return ver[x2][y2] - ver[x1][y2] - ver[x2][y1 - 1] + ver[x1][y1 - 1];
}
int get(int x1, int y1, int x2, int y2) {
  if ((x1 > x2) || (y1 > y2)) return 0;
  if (x1 == x2) return get_hor(x1, y1, x2, y2);
  if (y1 == y2) return get_ver(x1, y1, x2, y2);
  return get_hor(x1, y1, x2, y2) + get_ver(x1, y1, x2, y2);
}
int main() {
  cin >> h >> w;
  char t[500 + 2];
  for (size_t i = 1; i <= h; i++) {
    cin >> t;
    for (size_t j = 1; j <= w; j++) arr[i][j] = (t[j - 1] == '.');
  }
  for (size_t i = 0; i <= h; i++) {
    hor[i][0] = 0;
    ver[i][0] = 0;
    arr[i][0] = false;
  }
  for (size_t j = 1; j <= w; j++) {
    hor[0][j] = 0;
    ver[0][j] = 0;
    arr[0][j] = false;
  }
  for (size_t i = 1; i <= h; i++) {
    for (size_t j = 1; j <= w; j++) {
      hor[i][j] = hor[i][j - 1] + hor[i - 1][j] - hor[i - 1][j - 1];
      ver[i][j] = ver[i][j - 1] + ver[i - 1][j] - ver[i - 1][j - 1];
      if (arr[i][j]) {
        if (arr[i - 1][j]) ver[i][j] += 1;
        if (arr[i][j - 1]) hor[i][j] += 1;
      }
    }
  }
  size_t q, x1, y1, x2, y2;
  cin >> q;
  for (size_t i = 0; i < q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << get(x1, y1, x2, y2) << endl;
  }
  return 0;
}
