#include <bits/stdc++.h>
using namespace std;
int hor[501][501];
int ver[501][501];
int main() {
  int r, c, r1, c1, c2, r2, i, j, sum = 0, q;
  cin >> r >> c;
  string str[501];
  for (i = 1; i <= r; i++) {
    cin >> str[i];
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j < c; j++) {
      if (str[i][j] == '.' && str[i][j - 1] == '.')
        hor[i][j] = hor[i][j - 1] + hor[i - 1][j] + 1 - hor[i - 1][j - 1];
      else
        hor[i][j] = hor[i][j - 1] + hor[i - 1][j] - hor[i - 1][j - 1];
    }
  }
  for (i = 0; i < c; i++) {
    for (j = 2; j <= r; j++) {
      if (i == 0) {
        if (str[j][i] == '.' && str[j - 1][i] == '.')
          ver[j][0] = ver[j - 1][0] + 1;
        else
          ver[j][0] = ver[j - 1][0];
      } else {
        if (str[j][i] == '.' && str[j - 1][i] == '.')
          ver[j][i] = ver[j - 1][i] + ver[j][i - 1] + 1 - ver[j - 1][i - 1];
        else
          ver[j][i] = ver[j - 1][i] + ver[j][i - 1] - ver[j - 1][i - 1];
      }
    }
  }
  cin >> q;
  sum = 0;
  for (i = 1; i <= q; i++) {
    cin >> r1 >> c1 >> r2 >> c2;
    sum = sum + hor[r2][c2 - 1] - hor[r1 - 1][c2 - 1] - hor[r2][c1 - 1] +
          hor[r1 - 1][c1 - 1];
    if (c1 >= 2)
      sum = sum + ver[r2][c2 - 1] + ver[r1][c1 - 2] - ver[r1][c2 - 1] -
            ver[r2][c1 - 2];
    else {
      sum = sum + ver[r2][c2 - 1] - ver[r1][c2 - 1];
    }
    cout << sum << endl;
    sum = 0;
  }
}
