#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
inline long long expo(long long base, int nent) {
  if (nent == 1)
    return base;
  else if (nent & 1) {
    long long temp = expo(base, nent / 2);
    temp = (temp * temp) % MOD * base;
    if (temp >= MOD) temp %= MOD;
    return temp;
  } else {
    long long temp = expo(base, nent / 2);
    temp *= temp;
    if (temp >= MOD) temp %= MOD;
    return temp;
  }
}
int rc[505][505], rw[505][505];
int main() {
  string x[505];
  int h, w, a, b, c, d, ans, q;
  cin >> h >> w;
  for (int i = 0; i < (int)h; i++) cin >> x[i];
  for (int i = 0; i < (int)h; i++)
    for (int j = 0; j < (int)w; j++) {
      if (j)
        rc[i][j] =
            rc[i][j - 1] + (x[i][j] == x[i][j - 1] && x[i][j] == '.' ? 1 : 0);
      if (i)
        rw[i][j] =
            rw[i - 1][j] + (x[i][j] == x[i - 1][j] && x[i][j] == '.' ? 1 : 0);
    }
  cin >> q;
  while (q--) {
    cin >> a >> b >> c >> d;
    ans = 0, a--, b--;
    for (int i = a; i < (int)c; i++) {
      if (!b)
        ans += rc[i][d - 1];
      else
        ans += (rc[i][d - 1] - rc[i][b]);
    }
    for (int i = b; i < (int)d; i++) {
      if (!a)
        ans += rw[c - 1][i];
      else
        ans += (rw[c - 1][i] - rw[a][i]);
    }
    cout << ans << endl;
  }
  return 0;
}
