#include <bits/stdc++.h>
using namespace std;
int b[600][600], upp[600][600], low[600][600];
char s[600][600];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> s[i][j];
      if (s[i][j] == '.') {
        b[i][j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      low[i][j] = low[i][j - 1];
      upp[i][j] = upp[i - 1][j];
      if (b[i][j] == 1) {
        if (b[i][j - 1] == 1) {
          low[i][j]++;
        }
        if (b[i - 1][j] == 1) {
          upp[i][j]++;
        }
      }
    }
  }
  int q;
  cin >> q;
  for (int w = 0; w < q; w++) {
    int r1, c1, r2, c2;
    int ans = 0;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    for (int i = r1; i <= r2; i++) {
      ans += low[i][c2] - low[i][c1];
    }
    for (int i = c1; i <= c2; i++) {
      ans += upp[r2][i] - upp[r1][i];
    }
    cout << ans << endl;
  }
  return 0;
}
