#include <bits/stdc++.h>
using namespace std;
void debug(vector<vector<int>> v) {
  cout << "[DEBUG]"
       << "\n";
  for (auto x : v) {
    for (auto y : x) cout << y << " ";
    cout << "\n";
  }
  cout << "\n";
}
int r, c;
vector<vector<int>> grid;
vector<vector<int>> prefix;
int get_grid(int x, int y) {
  if (x < 0 || y < 0) return '#';
  return grid[x][y];
}
int get_prefix(int x, int y) {
  if (x < 0 || y < 0) return 0;
  return prefix[x][y];
}
void create_prefix() {
  prefix.assign(r, vector<int>(c, 0));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      prefix[i][j] = get_prefix(i - 1, j) + get_prefix(i, j - 1) -
                     get_prefix(i - 1, j - 1);
      if (get_grid(i, j) == '.' && get_grid(i - 1, j) == '.') prefix[i][j] += 1;
      if (get_grid(i, j) == '.' && get_grid(i, j - 1) == '.') prefix[i][j] += 1;
    }
  }
}
void solve() {
  cin >> r >> c;
  grid.resize(r, vector<int>(c, 0));
  for (int i = 0; i < r; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < c; j++) grid[i][j] = s[j];
  }
  create_prefix();
  int Q;
  cin >> Q;
  while (Q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    y1--;
    x2--;
    y2--;
    int ret = get_prefix(x2, y2) - get_prefix(x2, y1 - 1) -
              get_prefix(x1 - 1, y2) + get_prefix(x1 - 1, y1 - 1);
    for (int i = y1; i <= y2; i++) {
      if (get_grid(x1, i) == '.' && get_grid(x1 - 1, i) == '.') ret--;
    }
    for (int i = x1; i <= x2; i++) {
      if (get_grid(i, y1) == '.' && get_grid(i, y1 - 1) == '.') ret--;
    }
    cout << ret << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  for (int tt = 0; tt < t; tt++) {
    solve();
  }
  return 0;
}
