#include <bits/stdc++.h>
using namespace std;
char a[510][510];
int dpr[510][510];
int dpc[510][510];
int main() {
  int h, w;
  cin >> h >> w;
  for (long int i = 1; i < h + 1; i++)
    for (long int j = 1; j < w + 1; j++) cin >> a[i][j];
  for (long int i = 1; i < h + 1; i++) {
    for (long int j = 2; j < w + 1; j++) {
      if (a[i][j] == '.' && a[i][j - 1] == '.')
        dpr[i][j] = dpr[i][j - 1] + 1;
      else
        dpr[i][j] = dpr[i][j - 1];
    }
  }
  for (long int i = 1; i < w + 1; i++) {
    for (long int j = 2; j < h + 1; j++) {
      if (a[j][i] == '.' && a[j - 1][i] == '.')
        dpc[j][i] = dpc[j - 1][i] + 1;
      else
        dpc[j][i] = dpc[j - 1][i];
    }
  }
  for (long int i = 1; i < h + 1; i++) {
    for (long int j = 1; j < w + 1; j++) dpr[i][j] += dpr[i - 1][j];
  }
  for (long int i = 1; i < w + 1; i++) {
    for (long int j = 1; j < h + 1; j++) dpc[j][i] += dpc[j][i - 1];
  }
  int q;
  cin >> q;
  int r1, c1, r2, c2;
  for (long int i = 0; i < q; i++) {
    cin >> r1 >> c1 >> r2 >> c2;
    int R = dpr[r2][c2] - dpr[r2][c1] - dpr[r1 - 1][c2] + dpr[r1 - 1][c1];
    int C = dpc[r2][c2] - dpc[r2][c1 - 1] - dpc[r1][c2] + dpc[r1][c1 - 1];
    cout << R + C << endl;
  }
}
