#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int abs1(long long int a) {
  if (a < 0)
    return -1 * a;
  else
    return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int h, w;
  cin >> h >> w;
  vector<string> v;
  int finv[504][504], finh[504][504];
  for (int i = 0; i < h; i++) {
    string t;
    cin >> t;
    v.push_back(t);
    for (int j = 0; j < w; j++) {
      finv[i][j] = 0;
      finh[i][j] = 0;
    }
  }
  for (int i = 1; i < w; i++) {
    if (v[0][i - 1] == '.' && v[0][i] == '.')
      finh[0][i] = finh[0][i - 1] + 1;
    else
      finh[0][i] = finh[0][i - 1];
  }
  for (int i = 1; i < h; i++) {
    if (v[i - 1][0] == '.' && v[i][0] == '.')
      finv[i][0] = finv[i - 1][0] + 1;
    else
      finv[i][0] = finv[i - 1][0];
  }
  for (int i = 1; i < h; i++) {
    for (int j = 1; j < w; j++) {
      finv[i][j] = finv[i][j - 1] + finv[i - 1][j] - finv[i - 1][j - 1];
      finh[i][j] = finh[i][j - 1] + finh[i - 1][j] - finh[i - 1][j - 1];
      if (v[i][j - 1] == '.' && v[i][j] == '.') finh[i][j]++;
      if (v[i - 1][j] == '.' && v[i][j] == '.') finv[i][j]++;
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    r2--;
    c1--;
    c2--;
    int ct = finh[r2][c2] + finv[r2][c2];
    if (r1 != 0 && c1 != 0) {
      ct -= (finv[r1][c2] + finh[r1 - 1][c2]);
      ct -= (finh[r2][c1] + finv[r2][c1 - 1]);
      ct += (finh[r1 - 1][c1] + finv[r1][c1 - 1]);
    } else if (r1 != 0)
      ct -= (finv[r1][c2] + finh[r1 - 1][c2]);
    else if (c1 != 0)
      ct -= (finh[r2][c1] + finv[r2][c1 - 1]);
    cout << ct << endl;
  }
  return 0;
}
