#include <bits/stdc++.h>
using namespace std;
int h, w;
char grid[510][510];
int row[510][510];
int column[510][510];
int q;
int ql, qr, qu, qd;
int main() {
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> grid[i][j];
    }
  }
  cin >> q;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= (w - 1); j++) {
      if (grid[i][j] == '.' && grid[i][j + 1] == '.') {
        row[i][j] = row[i][j - 1] + 1;
      } else {
        row[i][j] = row[i][j - 1];
      }
    }
  }
  for (int i = 1; i <= w; i++) {
    for (int j = 1; j <= (h - 1); j++) {
      if (grid[j][i] == '.' && grid[j + 1][i] == '.') {
        column[j][i] = column[j - 1][i] + 1;
      } else {
        column[j][i] = column[j - 1][i];
      }
    }
  }
  int ans = 0;
  for (int j = 1; j <= q; j++) {
    cin >> qu >> ql >> qd >> qr;
    ans = 0;
    for (int i = qu; i <= qd; i++) {
      ans += (row[i][qr - 1] - row[i][ql - 1]);
    }
    for (int i = ql; i <= qr; i++) {
      ans += (column[qd - 1][i] - column[qu - 1][i]);
    }
    cout << ans << endl;
  }
}
