#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
char g[maxn][maxn];
int d[maxn][maxn], r[maxn][maxn];
int sd[maxn][maxn], sr[maxn][maxn];
int ssr[maxn][maxn], ssd[maxn][maxn];
int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; ++i) {
    scanf("%s", g[i]);
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (g[i][j] == '#') continue;
      if (i + 1 < h && g[i + 1][j] == '.') d[i + 1][j + 1]++;
      if (j + 1 < w && g[i][j + 1] == '.') r[i + 1][j + 1]++;
    }
  }
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      ssd[i][j] = ssd[i][j - 1] + d[i][j];
      ssr[i][j] = ssr[i - 1][j] + r[i][j];
      sd[i][j] = sd[i][j - 1] + sd[i - 1][j] - sd[i - 1][j - 1] + d[i][j];
      sr[i][j] = sr[i][j - 1] + sr[i - 1][j] - sr[i - 1][j - 1] + r[i][j];
    }
  }
  int q, x1, y1, x2, y2;
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    int num1 =
        sd[x2][y2] - sd[x2][y1 - 1] - sd[x1 - 1][y2] + sd[x1 - 1][y1 - 1];
    int num2 =
        sr[x2][y2] - sr[x2][y1 - 1] - sr[x1 - 1][y2] + sr[x1 - 1][y1 - 1];
    num1 -= (ssd[x2][y2] - ssd[x2][y1 - 1]);
    num2 -= (ssr[x2][y2] - ssr[x1 - 1][y2]);
    printf("%d\n", num1 + num2);
  }
  return 0;
}
