#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int r, c;
  cin >> r >> c;
  int grid[r][c];
  int row[r][c];
  int col[r][c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      char ch;
      cin >> ch;
      if (ch == '#')
        grid[i][j] = 0;
      else
        grid[i][j] = 1;
    }
  }
  for (int i = 0; i < r; i++) row[i][0] = 0;
  for (int i = 0; i < c; i++) col[0][i] = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 1; j < c; 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 j = 0; j < c; j++) {
    for (int i = 1; i < r; i++) {
      if (grid[i][j] && grid[i - 1][j])
        col[i][j] = col[i - 1][j] + 1;
      else
        col[i][j] = col[i - 1][j];
    }
  }
  for (int i = 1; i < r; i++) {
    for (int j = 0; j < c; j++) {
      row[i][j] += row[i - 1][j];
    }
  }
  for (int j = 1; j < c; j++) {
    for (int i = 0; i < r; i++) {
      col[i][j] += col[i][j - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long ans = 0;
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    c1--;
    c2--;
    r2--;
    ans += row[r2][c2] - (r1 > 0 ? row[r1 - 1][c2] : 0) -
           (c1 > 0 ? row[r2][c1 - 1] : 0) +
           (r1 > 0 && c1 > 0 ? row[r1 - 1][c1 - 1] : 0);
    ans += col[r2][c2] - (r1 > 0 ? col[r1 - 1][c2] : 0) -
           (c1 > 0 ? col[r2][c1 - 1] : 0) +
           (r1 > 0 && c1 > 0 ? col[r1 - 1][c1 - 1] : 0);
    for (int i = r1; i < r2 + 1; i++) {
      if (c1 > 0 && grid[i][c1] == grid[i][c1 - 1] && grid[i][c1] == 1) ans--;
    }
    for (int i = c1; i < c2 + 1; i++) {
      if (r1 > 0 && grid[r1][i] == grid[r1 - 1][i] && grid[r1][i] == 1) ans--;
    }
    cout << ans << endl;
  }
}
