#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  int h[n + 1][m], v[n][m + 1];
  memset(h, 0, sizeof(h));
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < m; j++) {
      h[i][j] = h[i][j - 1];
      if (arr[i - 1][j] == '.' && arr[i - 1][j - 1] == arr[i - 1][j])
        h[i][j] += 1;
    }
    for (int j = 1; j < m; j++) {
      h[i][j] += h[i - 1][j];
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i < n; i++) {
      v[i][j] = v[i - 1][j];
      if (arr[i][j - 1] == '.' && arr[i - 1][j - 1] == '.') v[i][j] += 1;
    }
    for (int i = 1; i < n; i++) {
      v[i][j] += v[i][j - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    cout << (h[r2][c2 - 1] - h[r2][c1 - 1] -
             (h[r1 - 1][c2 - 1] - h[r1 - 1][c1 - 1])) +
                (v[r2 - 1][c2] - v[r2 - 1][c1 - 1] -
                 (v[r1 - 1][c2] - v[r1 - 1][c1 - 1]))
         << "\n";
  }
  return 0;
}
