#include <bits/stdc++.h>
using namespace std;
const int _N = 510;
int n, m;
int f[_N][_N];
int s[_N][_N][2];
int main() {
  scanf("%d%d", &n, &m);
  static char get_s[_N];
  for (int i = 1; i <= n; i++) {
    scanf("%s", get_s + 1);
    for (int j = 1; j <= m; j++)
      if (get_s[j] == '.') f[i][j] = 1;
  }
  static int _x, _y;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      s[i][j][0] = s[i - 1][j][0] + s[i][j - 1][0] - s[i - 1][j - 1][0] +
                   (f[i + 1][j] && f[i][j]);
      s[i][j][1] = s[i - 1][j][1] + s[i][j - 1][1] - s[i - 1][j - 1][1] +
                   (f[i][j + 1] && f[i][j]);
    }
  static int q, __x, __y;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d%d", &_x, &_y, &__x, &__y);
    static int re;
    re = s[__x - 1][__y][0] - s[_x - 1][__y][0] - s[__x - 1][_y - 1][0] +
         s[_x - 1][_y - 1][0];
    re += s[__x][__y - 1][1] - s[_x - 1][__y - 1][1] - s[__x][_y - 1][1] +
          s[_x - 1][_y - 1][1];
    printf("%d\n", re);
  }
  return 0;
}
