#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 5;
char g[N][N];
int f[N][N];
int w, h, q;
void DP() {
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) {
      f[i][j] = f[i][j - 1] + f[i - 1][j] - f[i - 1][j - 1];
      if (g[i][j - 1] == '.' && g[i][j] == '.') f[i][j]++;
      if (g[i][j] == '.' && g[i - 1][j] == '.') f[i][j]++;
    }
}
void Read() {
  memset(g, '#', sizeof(g));
  cin >> h >> w;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= w; j++) cin >> g[i][j];
}
void Solve() {
  DP();
  cin >> q;
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int ans = f[x2][y2] - f[x1 - 1][y2] - f[x2][y1 - 1] + f[x1 - 1][y1 - 1];
    for (int i = y1; i <= y2; i++)
      if (g[x1 - 1][i] == '.' && g[x1][i] == '.') ans--;
    for (int i = x1; i <= x2; i++)
      if (g[i][y1 - 1] == '.' && g[i][y1] == '.') ans--;
    cout << ans << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  Read();
  Solve();
  return 0;
}
