#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 256;
const char nxtl = '\n';
const double begTime = clock();
const double eps = (double)1e-9;
inline double Time() {
  double endTime = clock();
  return ((endTime - begTime) / CLOCKS_PER_SEC);
}
inline void CTime() { cerr << setprecision(6) << fixed << Time() << nxtl; }
int n, m, str[555][555], stl[555][555], str2[555][555], stl2[555][555];
char c[555][555];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c[i][j];
      if (c[i][j] == '.')
        str[i][j] = str[i][j - 1] + 1, stl[i][j] = stl[i - 1][j] + 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j] == '#') {
        str2[i][j] = str2[i][j - 1], stl2[i][j] = stl2[i - 1][j];
        if (c[i][j - 1] != '#')
          for (int x = j + 1; x <= m; ++x) str2[i][x] = str2[i][j];
        if (c[i - 1][j] != '#')
          for (int x = i + 1; x <= n; ++x) stl2[x][j] = stl2[i][j];
      } else {
        str2[i][j] += max(str[i][j] - 1, 0);
        stl2[i][j] += max(stl[i][j] - 1, 0);
      }
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, y, x2, y2;
    scanf("%d%d%d%d", &x, &y, &x2, &y2);
    int res = 0;
    for (int i = x; i <= x2; ++i) {
      res += str2[i][y2] - str2[i][y];
    }
    for (int j = y; j <= y2; ++j) {
      res += stl2[x2][j] - stl2[x][j];
    }
    printf("%d\n", res);
  }
  return 0;
}
