#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
char c[505][505];
int byx[505][505], byy[505][505];
bool check(int x1, int y1, int x2, int y2) {
  if (c[x1][y1] == '#') return 0;
  if (c[x2][y2] == '#') return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j < w; j++) {
      if (check(i, j, i, j + 1)) {
        byx[i][j + 1] = 1;
      }
    }
  }
  for (int i = 1; i < h; i++) {
    for (int j = 1; j <= w; j++) {
      if (check(i, j, i + 1, j)) {
        byy[i + 1][j] = 1;
      }
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      byx[i][j] += byx[i - 1][j] + byx[i][j - 1] - byx[i - 1][j - 1];
      byy[i][j] += byy[i - 1][j] + byy[i][j - 1] - byy[i - 1][j - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << byx[x2][y2] - byx[x1 - 1][y2] - byx[x2][y1] + byx[x1 - 1][y1] +
                byy[x2][y2] - byy[x1][y2] - byy[x2][y1 - 1] + byy[x1][y1 - 1]
         << '\n';
  }
}
