#include <bits/stdc++.h>
using namespace std;
const int MAX = 505;
int a[MAX][MAX];
int dwsame[MAX][MAX];
int rwsame[MAX][MAX];
char row[MAX][MAX];
int q, r, c;
int getA(int first, int second) {
  if (a[first][second] != -1) return a[first][second];
  int ans = 0;
  ans += getA(first - 1, second) + getA(first, second - 1) -
         getA(first - 1, second - 1);
  ans +=
      (row[first][second] == '#' ? 0
                                 : (row[first][second - 1] == '#' ? 0 : 1) +
                                       (row[first - 1][second] == '#' ? 0 : 1));
  return a[first][second] = ans;
}
int getdw(int first, int second) {
  if (dwsame[first][second] != -1) return dwsame[first][second];
  int ans = getdw(first, second - 1) +
            (row[first][second] == '#' ? 0 : row[first + 1][second] == '.');
  return dwsame[first][second] = ans;
}
int getrw(int first, int second) {
  if (rwsame[first][second] != -1) return rwsame[first][second];
  int ans = getrw(first - 1, second) +
            (row[first][second] == '#' ? 0 : row[first][second + 1] == '.');
  return rwsame[first][second] = ans;
}
void init() {
  for (int i = 0; i <= max(r, c); i++) {
    a[i][0] = a[0][i] = 0;
    dwsame[0][i] = dwsame[i][0] = 0;
    rwsame[0][i] = rwsame[i][0] = 0;
    row[0][i] = row[i][0] = '#';
  }
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      a[i][j] = -1;
      dwsame[i][j] = -1;
      rwsame[i][j] = -1;
    }
  }
  a[1][1] = 0;
}
void printA() {
  cout << "printing A\n";
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
int main() {
  cin >> r >> c;
  init();
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      cin >> row[i][j];
    }
  }
  cin >> q;
  int r1, c1, r2, c2;
  for (int i = 0; i < q; i++) {
    cin >> r1 >> c1 >> r2 >> c2;
    int res = 0;
    res += getA(r2, c2) + getA(r1 - 1, c1 - 1) - getA(r2, c1 - 1) -
           getA(r1 - 1, c2);
    res -= getdw(r1 - 1, c2) - getdw(r1 - 1, c1 - 1);
    res -= getrw(r2, c1 - 1) - getrw(r1 - 1, c1 - 1);
    cout << res << endl;
  }
}
