#include <bits/stdc++.h>
using namespace std;
const int M = 510;
const int N = 1e5 + 10;
int h, w;
string s[M];
int q, a[N], b[N], c[N], d[N];
int dph[M][M], dpw[M][M];
int ans;
void input() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> s[i];
  cin >> q;
  for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
}
void bsdps() {
  for (int i = 1; i < w; i++)
    if ((s[0])[i] == (s[0])[i - 1] and (s[0])[i] == '.')
      dph[0][i] = dph[0][i - 1] + 1;
    else
      dph[0][i] = dph[0][i - 1];
  for (int i = 1; i < h; i++)
    if ((s[i])[0] == (s[i - 1])[0] and (s[i])[0] == '.')
      dpw[i][0] = dpw[i - 1][0] + 1;
    else
      dpw[i][0] = dpw[i - 1][0];
}
void dps() {
  for (int i = 1; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if ((s[i])[j] == (s[i])[j - 1] and (s[i])[j] == '.')
        dph[i][j] = dph[i - 1][j] + dph[i][j - 1] - dph[i - 1][j - 1] + 1;
      else
        dph[i][j] = dph[i - 1][j] + dph[i][j - 1] - dph[i - 1][j - 1];
    }
  }
  for (int z = 1; z < w; z++)
    for (int g = 1; g < h; g++)
      if ((s[g])[z] == (s[g - 1])[z] and (s[g])[z] == '.')
        dpw[g][z] = dpw[g - 1][z] + dpw[g][z - 1] - dpw[g - 1][z - 1] + 1;
      else
        dpw[g][z] = dpw[g - 1][z] + dpw[g][z - 1] - dpw[g - 1][z - 1];
}
void output() {
  for (int i = 0; i < q; i++) {
    if (a[i] == 1 and b[i] == 1)
      ans = dph[c[i] - 1][d[i] - 1] + dpw[c[i] - 1][d[i] - 1];
    else if (a[i] == 1) {
      ans = dph[c[i] - 1][d[i] - 1] + dpw[c[i] - 1][d[i] - 1];
      ans = ans - (dph[c[i] - 1][b[i] - 1] + dpw[c[i] - 1][b[i] - 2]);
    } else if (b[i] == 1) {
      ans = dph[c[i] - 1][d[i] - 1] + dpw[c[i] - 1][d[i] - 1];
      ans = ans - (dph[a[i] - 2][d[i] - 1] + dpw[a[i] - 1][d[i] - 1]);
    } else {
      ans = dph[c[i] - 1][d[i] - 1] + dpw[c[i] - 1][d[i] - 1];
      ans = ans - (dpw[a[i] - 1][d[i] - 1] + dpw[c[i] - 1][b[i] - 2]);
      ans = ans - (dph[a[i] - 2][d[i] - 1] + dph[c[i] - 1][b[i] - 1]);
      ans = ans + (dph[a[i] - 2][b[i] - 1] + dpw[a[i] - 1][b[i] - 2]);
    }
    cout << ans << "\n";
  }
}
int main() {
  input();
  bsdps();
  dps();
  output();
}
