#include <bits/stdc++.h>
using namespace std;
long long power(long long x, unsigned long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long powermod(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void print2d(long long *mat, long long n, long long m) {
  for (long long i = 0; i < (n); i++) {
    for (long long j = 0; j < (m); j++) {
      cout << *(mat + i * m + j) << " ";
    }
    cout << endl;
  }
}
void printarr(long long *arr, long long n) {
  for (long long i = 0; i < (n); i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
void init(long long *arr, long long n, long long val) {
  for (long long i = (0); i < (n); i++) {
    arr[i] = val;
  }
}
void init2d(long long *arr, long long n, long long m, long long val) {
  for (long long i = (0); i < (n); i++) {
    for (long long j = (0); j < (m); j++) {
      *(arr + i * m + j) = val;
    }
  }
}
double mpi = 2 * acos(0.0);
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  string str[n];
  for (long long i = (0); i < (n); i++) {
    cin >> str[i];
  }
  long long a[n + 1][m + 1], b[n + 1][m + 1];
  n++;
  m++;
  init2d((long long *)a, n, m, 0);
  init2d((long long *)b, n, m, 0);
  for (long long i = (1); i < (n); i++) {
    for (long long j = (1); j < (m - 1); j++) {
      if (str[i - 1][j - 1] == '.' && str[i - 1][j + 1 - 1] == '.') {
        a[i][j] = 1;
      }
    }
  }
  for (long long j = (1); j < (m); j++) {
    for (long long i = (1); i < (n - 1); i++) {
      if (str[i + 1 - 1][j - 1] == '.' && str[i - 1][j - 1] == '.') {
        b[i][j] = 1;
      }
    }
  }
  for (long long i = (1); i < (n); i++) {
    for (long long j = (2); j < (m); j++) {
      a[i][j] += a[i][j - 1];
    }
  }
  for (long long j = (1); j < (m); j++) {
    for (long long i = (2); i < (n); i++) {
      a[i][j] += a[i - 1][j];
    }
  }
  for (long long j = (1); j < (m); j++) {
    for (long long i = (2); i < (n); i++) {
      b[i][j] += b[i - 1][j];
    }
  }
  for (long long i = (1); i < (n); i++) {
    for (long long j = (2); j < (m); j++) {
      b[i][j] += b[i][j - 1];
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    c2--;
    long long ans =
        a[r2][c2] - a[r2][c1 - 1] - a[r1 - 1][c2] + a[r1 - 1][c1 - 1];
    c2++;
    r2--;
    ans += b[r2][c2] - b[r2][c1 - 1] - b[r1 - 1][c2] + b[r1 - 1][c1 - 1];
    cout << ans << endl;
  }
}
