#include <bits/stdc++.h>
using namespace std;
int fx4[] = {+1, -1, +0, +0};
int fy4[] = {+0, +0, +1, -1};
int fx8[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int fy8[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int h, w;
bool check(int i, int j) {
  if (i < 0 || j < 0 || i == h || j == w) {
    return false;
  } else
    return true;
}
int main() {
  std::ios::sync_with_stdio(false);
  char c;
  int arr[507][507], sidearr[507][507], uparr[507][507];
  memset(sidearr, -1, sizeof sidearr);
  memset(uparr, -1, sizeof uparr);
  memset(arr, -1, sizeof arr);
  cin >> h >> w;
  for (int i = int(0); i <= int(h - 1); i++) {
    for (int j = int(0); j <= int(w - 1); j++) {
      cin >> c;
      if (c == '.') {
        arr[i][j] = 0;
      } else {
        arr[i][j] = 1;
      }
    }
  }
  for (int i = int(0); i <= int(w - 1); i++) {
    int number = 0;
    for (int j = int(0); j <= int(h - 1); j++) {
      uparr[j][i] = number;
      if (arr[j][i] == 0) {
        if (check(j - 1, i)) {
          if (arr[j - 1][i] == 0) {
            uparr[j][i] = number + 1;
            number++;
          } else
            uparr[j][i] = number;
        } else {
          uparr[j][i] = number;
        }
      } else {
        uparr[j][i] = number;
      }
    }
  }
  for (int i = int(0); i <= int(h - 1); i++) {
    int number = 0;
    for (int j = int(0); j <= int(w - 1); j++) {
      sidearr[i][j] = number;
      if (arr[i][j] == 0) {
        if (check(i, j + 1)) {
          if (arr[i][j + 1] == 0) {
            sidearr[i][j] = number + 1;
            number++;
          } else
            sidearr[i][j] = number;
        } else {
          sidearr[i][j] = number;
        }
      } else {
        sidearr[i][j] = number;
      }
    }
  }
  int queries;
  cin >> queries;
  int x1, y1, x2, y2;
  for (int i = int(0); i <= int(queries - 1); i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    long long answer = 0;
    for (int I = int(x1); I <= int(x2); I++) {
      if (y1 >= 1 && y2 >= 1)
        answer += (sidearr[I][y2 - 1] - sidearr[I][y1 - 1]);
      else if (y2 >= 1)
        answer += sidearr[I][y2 - 1];
    }
    for (int I = int(y1); I <= int(y2); I++) {
      answer += (uparr[x2][I] - uparr[x1][I]);
    }
    cout << answer << "\n";
  }
  return 0;
}
