#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
int n, m, q, a, b, c, d;
int f[505][505], s[505][505], h[505][505];
char mp[505][505];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int tmp1 = 0, tmp2 = 0;
      if (mp[i][j] == '.') {
        if (mp[i - 1][j] == '.') tmp1 = 1;
        if (mp[i][j - 1] == '.') tmp2 = 1;
      }
      f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + tmp1 + tmp2;
      s[i][j] = s[i - 1][j] + tmp1;
      h[i][j] = h[i][j - 1] + tmp2;
    }
  }
  q = read();
  for (int i = 1; i <= q; i++) {
    a = read(), b = read(), c = read(), d = read();
    printf("%d\n", f[c][d] - f[c][b] - f[a][d] + f[a][b] + h[a][d] - h[a][b] +
                       s[c][b] - s[a][b]);
  }
  return 0;
}
