#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
char s[505][505];
long long sum[505][505];
int m, n;
int main() {
  while (~scanf("%d%d", &m, &n)) {
    for (int i = 1; i <= m; i++) scanf("%s", s[i] + 1);
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= n; j++) {
        sum[i][j] = sum[i - 1][j - 1];
        for (int k = 1; k <= i - 1; k++)
          if (s[k][j - 1] == '.' && s[k][j] == '.') sum[i][j]++;
        for (int k = 1; k <= j - 1; k++)
          if (s[i - 1][k] == '.' && s[i][k] == '.') sum[i][j]++;
        for (int k = 1; k <= j - 1; k++)
          if (s[i][k] == '.' && s[i][k + 1] == '.') sum[i][j]++;
        for (int k = 1; k <= i - 1; k++)
          if (s[k][j] == '.' && s[k + 1][j] == '.') sum[i][j]++;
      }
    }
    int q, r1, c1, r2, c2;
    scanf("%d", &q);
    while (q--) {
      scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
      long long ans =
          sum[r2][c2] - sum[r1 - 1][c2] - sum[r2][c1 - 1] + sum[r1 - 1][c1 - 1];
      for (int i = r1; i <= r2; i++)
        if (s[i][c1 - 1] == '.' && s[i][c1] == '.') ans--;
      for (int i = c1; i <= c2; i++)
        if (s[r1 - 1][i] == '.' && s[r1][i] == '.') ans--;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
