#include <bits/stdc++.h>
using namespace std;
const long long N = 500 + 10;
;
int n, m;
long long f[N][N], ch[N][N], cc[N][N];
char a[N][N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
      if (a[i][j] == '.')
        f[i][j] += (a[i - 1][j] == '.') + (a[i][j - 1] == '.');
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      ch[i][j] = ch[i - 1][j];
      if (a[i][j] == a[i][j + 1] && a[i][j] == '.') ch[i][j] += 1;
    }
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++) {
      cc[i][j] = cc[i][j - 1];
      if (a[i][j] == a[i + 1][j] && a[i][j] == '.') cc[i][j] += 1;
    }
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x, y, u, v;
    scanf("%d %d %d %d", &x, &y, &u, &v);
    printf("%I64d\n", f[u][v] - f[x - 1][v] - f[u][y - 1] + f[x - 1][y - 1] -
                          cc[x - 1][v] - ch[u][y - 1] + cc[x - 1][y - 1] +
                          ch[x - 1][y - 1]);
  }
}
