#include <bits/stdc++.h>
using namespace std;
vector<long long int> v1, v2, v3, v4;
vector<pair<long long int, long long int> > vec, vec1;
vector<long long int> adj[200005];
map<long long int, long long int> Mp;
set<long long int> st, st1, st2;
queue<long long int> Q;
stack<long long int> Stk;
multiset<long long int> S;
long long int t, T, n, m, k, a, b, row, col;
vector<long long int> v(200005);
void Reset() {}
void pre() {}
char s[505][505];
int A[505][505];
int B[505][505];
void Input() {
  cin >> row >> col;
  for (int i = 1; i <= row; i++) {
    for (int j = 1; j <= col; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= row; i++) {
    for (int j = 1; j <= col; j++) {
      if (s[i][j] == '.' && s[i][j - 1] == '.') {
        A[i][j] = A[i][j - 1] + 1;
      } else {
        A[i][j] = A[i][j - 1];
      }
    }
  }
  for (int i = 1; i <= col; i++) {
    for (int j = 1; j <= row; j++) {
      if (s[j][i] == '.' && s[j - 1][i] == '.') {
        B[j][i] = B[j - 1][i] + 1;
      } else {
        B[j][i] = B[j - 1][i];
      }
    }
  }
}
void Calculation() {
  cin >> n;
  long long int r1, r2, c1, c2;
  while (n--) {
    long long int sum = 0;
    cin >> r1 >> c1 >> r2 >> c2;
    for (int i = r1; i <= r2; i++) {
      sum += A[i][c2] - A[i][c1];
    }
    for (int i = c1; i <= c2; i++) {
      sum += B[r2][i] - B[r1][i];
    }
    cout << sum << endl;
  }
}
void solve() {
  Reset();
  Input();
  Calculation();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  pre();
  t = 1;
  while (t--) {
    T++;
    solve();
  }
  return 0;
}
