#include <bits/stdc++.h>
using namespace std;
char grid[555][555];
long long dp[555][555], sol, i, j, x, y, a, b, n, m, q, ori[555][555],
    ver[555][555];
int oriz(int x, int y) {
  if (grid[x][y] == '.' && grid[x][y - 1] == '.') return 1;
  return 0;
}
int vert(int x, int y) {
  if (grid[x][y] == '.' && grid[x - 1][y] == '.') return 1;
  return 0;
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> (grid[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + oriz(i, j) + vert(i, j) -
                 dp[i - 1][j - 1];
      ori[i][j] = ori[i][j - 1] + vert(i, j);
      ver[i][j] = ver[i - 1][j] + oriz(i, j);
    }
  cin >> q;
  for (; q; q--) {
    cin >> x >> y >> a >> b;
    sol = dp[a][b] - dp[a][y - 1] - dp[x - 1][b] + dp[x - 1][y - 1] -
          (ver[a][y] - ver[x - 1][y]) - (ori[x][b] - ori[x][y - 1]);
    cout << sol << '\n';
  }
  return 0;
}
