#include <bits/stdc++.h>
using namespace std;
const int LEN = 510;
string s[LEN];
int a[LEN][LEN];
int pr[LEN][LEN];
bool b[LEN][LEN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '.')
        a[i][j] = 0;
      else {
        if ((i > 0) && (s[i - 1][j] != '#')) ++a[i][j];
        if ((j > 0) && (s[i][j - 1] != '#')) ++a[i][j];
        if ((i < n - 1)) ++a[i][j];
        if ((j < m - 1)) ++a[i][j];
      }
      int npr = 0;
      if (i > 0) npr += pr[i - 1][j];
      if (j > 0) npr += pr[i][j - 1];
      if ((i > 0) && (j > 0)) npr -= pr[i - 1][j - 1];
      npr += a[i][j];
      pr[i][j] = npr;
    }
  }
  int q, x1, y1, x2, y2, n1, m1, ans, wb, na;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    --x1;
    --y1;
    --x2;
    --y2;
    n1 = x2 - x1 + 1;
    m1 = y2 - y1 + 1;
    ans = (n1 - 1) * m1 + (m1 - 1) * n1;
    wb = pr[x2][y2];
    if (x1 > 0) wb -= pr[x1 - 1][y2];
    if (y1 > 0) wb -= pr[x2][y1 - 1];
    if ((x1 > 0) && (y1 > 0)) wb += pr[x1 - 1][y1 - 1];
    for (int j = y1; j <= y2; ++j) {
      if (s[x1][j] == '#') {
        wb -= a[x1][j];
        if ((j > y1) && (s[x1][j - 1] != '#')) ++wb;
        if (x1 < x2) ++wb;
        if (j < y2) ++wb;
      }
    }
    for (int j = x1 + 1; j <= x2; ++j) {
      if (s[j][y1] == '#') {
        wb -= a[j][y1];
        if ((j > x1) && (s[j - 1][y1] != '#')) ++wb;
        if (j < x2) ++wb;
        if (y1 < y2) ++wb;
      }
    }
    if (y1 != y2) {
      for (int j = x1 + 1; j <= x2 - 1; ++j) {
        if (s[j][y2] == '#') {
          wb -= a[j][y2];
          if ((j > x1) && (s[j - 1][y2] != '#')) ++wb;
          if ((y2 > y1) && (s[j][y2 - 1] != '#')) ++wb;
          if (j < x2) ++wb;
        }
      }
    }
    if (x1 != x2) {
      for (int j = y1 + 1; j <= y2; ++j) {
        if (s[x2][j] == '#') {
          wb -= a[x2][j];
          if ((x2 > x1) && (s[x2 - 1][j] != '#')) ++wb;
          if ((j > y1) && (s[x2][j - 1] != '#')) ++wb;
          if (j < y2) ++wb;
        }
      }
    }
    if (ans - wb <= 0)
      printf("0\n");
    else
      printf("%d\n", ans - wb);
  }
  return 0;
}
