#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int n, M;
long long tree[505 << 2][505 << 2];
char a[505][505];
void build_y(int vx, int lx, int hx, int node, int l, int h) {
  if (l == h) {
    if (lx == hx)
      tree[vx][node] = 0;
    else {
      int mx = (lx + hx) >> 1;
      tree[vx][node] = tree[vx << 1][node] + tree[(vx << 1) | 1][node] +
                       (a[mx][l] == '.' && a[mx + 1][l] == '.');
    }
  } else {
    int lc = node << 1, rc = lc | 1, m = (l + h) >> 1;
    build_y(vx, lx, hx, lc, l, m);
    build_y(vx, lx, hx, rc, m + 1, h);
    tree[vx][node] = tree[vx][lc] + tree[vx][rc];
    for (int i = lx; i <= hx; ++i)
      if (a[i][m] == '.' && a[i][m + 1] == '.') ++tree[vx][node];
  }
}
void build_x(int node, int l, int h) {
  if (l != h) {
    int lc = node << 1, rc = lc | 1, m = (l + h) >> 1;
    build_x(lc, l, m);
    build_x(rc, m + 1, h);
  }
  build_y(node, l, h, 1, 0, M - 1);
}
long long query_y(int vx, int lx, int hx, int node, int l, int h, int y1,
                  int y2) {
  if (l == y1 && h == y2) return tree[vx][node];
  int lc = node << 1, rc = lc | 1, m = (l + h) >> 1;
  if (y2 <= m) return query_y(vx, lx, hx, lc, l, m, y1, y2);
  if (y1 > m) return query_y(vx, lx, hx, rc, m + 1, h, y1, y2);
  long long ret = query_y(vx, lx, hx, lc, l, m, y1, m) +
                  query_y(vx, lx, hx, rc, m + 1, h, m + 1, y2);
  for (int i = lx; i <= hx; ++i)
    if (a[i][m] == '.' && a[i][m + 1] == '.') ++ret;
  return ret;
}
long long query_x(int node, int l, int h, int x1, int x2, int y1, int y2) {
  if (l == x1 && h == x2) return query_y(node, l, h, 1, 0, M - 1, y1, y2);
  int lc = node << 1, rc = lc | 1, m = (l + h) >> 1;
  if (x2 <= m) return query_x(lc, l, m, x1, x2, y1, y2);
  if (x1 > m) return query_x(rc, m + 1, h, x1, x2, y1, y2);
  long long ret = query_x(lc, l, m, x1, m, y1, y2) +
                  query_x(rc, m + 1, h, m + 1, x2, y1, y2);
  for (int i = y1; i <= y2; ++i)
    if (a[m][i] == '.' && a[m + 1][i] == '.') ++ret;
  return ret;
}
int main() {
  int x1, x2, y1, y2, q;
  scanf("%d%d", &n, &M);
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  build_x(1, 0, n - 1);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &x1, &y1);
    scanf("%d%d", &x2, &y2);
    printf("%lld\n", query_x(1, 0, n - 1, x1 - 1, x2 - 1, y1 - 1, y2 - 1));
  }
  return 0;
}
