#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int INF = 1e9;
const double EPS = 1e-10;
const int N = 500, Q = 1e5;
int n, m;
char ar[N + 5][N + 5];
int prefH[N + 5][N + 5], prefV[N + 5][N + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", ar[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      prefH[i][j] = prefH[i][j - 1];
      if (ar[i][j] == '.' && ar[i][j - 1] == '.') ++prefH[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < n; j++) {
      prefV[j][i] = prefV[j - 1][i];
      if (ar[j][i] == '.' && ar[j - 1][i] == '.') ++prefV[j][i];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int r1, c1, r2, c2;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    long long tot = 0;
    r1--;
    r2--;
    c1--;
    c2--;
    for (int i = r1; i <= r2; i++) {
      tot += prefH[i][c2] - prefH[i][c1];
    }
    for (int i = c1; i <= c2; i++) {
      tot += prefV[r2][i] - prefV[r1][i];
    }
    printf("%lld\n", tot);
  }
  return 0;
}
