#include <bits/stdc++.h>
using namespace std;
int h, w, y[505][505], z[505][505], q, r1, c1, r2, c2, ans;
string x[505];
int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> x[i];
  }
  for (int i = 2; i <= w; i++) {
    y[1][i] = y[1][i - 1];
    if (x[0][i - 1] == x[0][i - 2] && x[0][i - 1] == '.') y[1][i]++;
  }
  for (int i = 2; i <= h; i++) {
    z[i][1] = z[i - 1][1];
    if (x[i - 1][0] == x[i - 2][0] && x[i - 1][0] == '.') z[i][1]++;
  }
  for (int i = 2; i <= h; i++) {
    for (int j = 2; j <= w; j++) {
      y[i][j] = y[i - 1][j] + y[i][j - 1] - y[i - 1][j - 1];
      if (x[i - 1][j - 1] == '.' && x[i - 1][j - 2] == '.') y[i][j]++;
      z[i][j] = z[i - 1][j] + z[i][j - 1] - z[i - 1][j - 1];
      if (x[i - 1][j - 1] == '.' && x[i - 2][j - 1] == '.') z[i][j]++;
    }
  }
  cin >> q;
  while (q--) {
    scanf("%d", &r1);
    scanf("%d", &c1);
    scanf("%d", &r2);
    scanf("%d", &c2);
    ans = y[r2][c2] - y[r1 - 1][c2] - y[r2][c1] + y[r1 - 1][c1];
    ans += (z[r2][c2] - z[r2][c1 - 1] - z[r1][c2] + z[r1][c1 - 1]);
    cout << ans << endl;
  }
  return 0;
}
