#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e9;
char a[502][502];
int row[502][502];
int col[502][502];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j <= m; j++) {
      if (a[i][j] == '.' && a[i][j - 1] == '.') row[i][j]++;
      row[i][j] += row[i][j - 1];
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 2; i <= n; i++) {
      if (a[i][j] == '.' && a[i - 1][j] == '.') col[i][j]++;
      col[i][j] += col[i - 1][j];
    }
  }
  cout << endl;
  int q;
  cin >> q;
  int x1, y1, x2, y2;
  int ans = 0;
  for (int i = 0; i < q; i++) {
    ans = 0;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    for (int j = x1; j <= x2; j++) ans += (row[j][y2] - row[j][y1]);
    for (int j = y1; j <= y2; j++) ans += (col[x2][j] - col[x1][j]);
    printf("%d\n", ans);
  }
}
