#include <bits/stdc++.h>
using namespace std;
const int MAX = 500;
char a[MAX][MAX];
int d[MAX][MAX];
int u[MAX][MAX];
int main() {
  int w, h, q;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < h; i++) {
    if (w < 2) continue;
    for (int j = 1; j < w; j++) {
      if (a[i][j] == '.' && a[i][j - 1] == '.')
        d[i][j] = d[i][j - 1] + 1;
      else
        d[i][j] = d[i][j - 1];
    }
  }
  for (int i = 0; i < w; i++) {
    if (h < 2) continue;
    for (int j = 1; j < h; j++) {
      if (a[j][i] == '.' && a[j - 1][i] == '.')
        u[i][j] = u[i][j - 1] + 1;
      else
        u[i][j] = u[i][j - 1];
    }
  }
  cin >> q;
  for (int i = 0, x1, y1, x2, y2; i < q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    int ans = 0;
    x1--;
    y1--;
    y2--;
    x2--;
    for (int j = x1; j <= x2; j++) {
      ans += d[j][y2] - d[j][y1];
    }
    for (int j = y1; j <= y2; j++) {
      ans += u[j][x2] - u[j][x1];
    }
    cout << ans << endl;
  }
}
