#include <bits/stdc++.h>
using namespace std;
char grid[550][550];
int dpr[550][550], dpc[550][550];
int ans[100010];
int main() {
  int h, w, q, r1, c1, r2, c2, k;
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++) scanf("%s", grid[i]);
  for (int i = 1; i <= h; i++) {
    dpr[i][1] = 0;
    for (int j = 2; j <= w; j++) {
      if (grid[i - 1][j - 1] == '.' && grid[i - 1][j - 2] == '.')
        dpr[i][j] = dpr[i][j - 1] + 1;
      else
        dpr[i][j] = dpr[i][j - 1];
    }
  }
  for (int j = 1; j <= w; j++) {
    dpc[1][j] = 0;
    for (int i = 2; i <= h; i++) {
      if (grid[i - 2][j - 1] == '.' && grid[i - 1][j - 1] == '.')
        dpc[i][j] = dpc[i - 1][j] + 1;
      else
        dpc[i][j] = dpc[i - 1][j];
    }
  }
  scanf("%d", &q);
  k = 0;
  while (q--) {
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    for (int i = r1; i <= r2; i++) ans[k] += dpr[i][c2] - dpr[i][c1];
    for (int j = c1; j <= c2; j++) ans[k] += dpc[r2][j] - dpc[r1][j];
    k++;
  }
  for (int i = 0; i < k; i++) printf("%d\n", ans[i]);
  return 0;
}
