#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 7;
int dpD[505][505], dpR[505][505];
char grid[505][505];
int n, m;
bool check(int i, int j) {
  if (i >= 1 && i <= n && j >= 1 && j <= m && grid[i][j] == '.') return true;
  return false;
}
int calR(int i1, int j1, int i2, int j2) {
  if (i1 > i2 || j1 > j2) return 0;
  return dpR[i2][j2] + dpR[i1 - 1][j1 - 1] - dpR[i1 - 1][j2] - dpR[i2][j1 - 1];
}
int calD(int i1, int j1, int i2, int j2) {
  if (i1 > i2 || j1 > j2) return 0;
  return dpD[i2][j2] + dpD[i1 - 1][j1 - 1] - dpD[i1 - 1][j2] - dpD[i2][j1 - 1];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dpD, 0, sizeof(dpD));
  memset(dpR, 0, sizeof(dpR));
  cin >> n >> m;
  char c;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dpR[i][j] = dpR[i - 1][j] + dpR[i][j - 1] - dpR[i - 1][j - 1];
      if (check(i, j) && check(i, j + 1)) dpR[i][j]++;
      dpD[i][j] = dpD[i - 1][j] + dpD[i][j - 1] - dpD[i - 1][j - 1];
      if (check(i, j) && check(i + 1, j)) dpD[i][j]++;
    }
  }
  int q;
  cin >> q;
  int i1, j1, i2, j2;
  for (int t = 0; t < q; t++) {
    cin >> i1 >> j1 >> i2 >> j2;
    int ans = 0;
    ans += calD(i1, j1, i2 - 1, j2 - 1);
    ans += calR(i1, j1, i2 - 1, j2 - 1);
    ans += calR(i2, j1, i2, j2 - 1);
    ans += calD(i1, j2, i2 - 1, j2);
    cout << ans << endl;
  }
}
