#include <bits/stdc++.h>
char board[512][512];
int row_cnt[512][512];
int col_cnt[512][512];
int row_on_border[512][512];
int col_on_border[512][512];
int main() {
  int row, col;
  scanf("%d%d", &row, &col);
  for (int r = 1; r <= row; ++r) {
    for (int c = 1; c <= col; ++c) {
      scanf("\n%c", &board[r][c]);
    }
  }
  for (int r = 1; r <= row; ++r) {
    int cur_cnt = 0;
    for (int c = 1; c <= col; ++c) {
      if (board[r][c] == '.' && board[r][c - 1] == '.') {
        row_on_border[r][c] = row_on_border[r - 1][c] + 1;
        ++cur_cnt;
      } else
        row_on_border[r][c] = row_on_border[r - 1][c];
      row_cnt[r][c] = row_cnt[r - 1][c] + cur_cnt;
    }
  }
  for (int c = 1; c <= col; ++c) {
    int cur_cnt = 0;
    for (int r = 1; r <= row; ++r) {
      if (board[r][c] == '.' && board[r - 1][c] == '.') {
        col_on_border[r][c] = col_on_border[r][c - 1] + 1;
        ++cur_cnt;
      } else
        col_on_border[r][c] = col_on_border[r][c - 1];
      col_cnt[r][c] = col_cnt[r][c - 1] + cur_cnt;
    }
  }
  int qry;
  scanf("%d", &qry);
  while (qry--) {
    int lrow, lcol, rrow, rcol;
    scanf("%d%d%d%d", &lrow, &lcol, &rrow, &rcol);
    printf("%d\n",
           row_cnt[rrow][rcol] - row_cnt[lrow - 1][rcol] -
               row_cnt[rrow][lcol - 1] + row_cnt[lrow - 1][lcol - 1] +
               col_cnt[rrow][rcol] - col_cnt[lrow - 1][rcol] -
               col_cnt[rrow][lcol - 1] + col_cnt[lrow - 1][lcol - 1] -
               row_on_border[rrow][lcol] + row_on_border[lrow - 1][lcol] -
               col_on_border[lrow][rcol] + col_on_border[lrow][lcol - 1]);
  }
  return 0;
}
