#include <bits/stdc++.h>
using namespace std;
const int MX = 1000;
char s[MX][MX];
long long ar[MX][MX];
long long dpr[MX][MX];
long long dpc[MX][MX];
int r, c;
int main() {
  int i, j, k, q;
  cin >> r >> c;
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) {
      cin >> s[i][j];
    }
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) {
      if (s[i][j] == '#')
        ar[i][j] = 0;
      else
        ar[i][j] = 1;
    }
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) {
      dpr[i][j] = dpr[i][j - 1];
      if (ar[i][j - 1] == 1 && ar[i][j] == 1) {
        dpr[i][j]++;
      }
    }
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) {
      dpr[i][j] += dpr[i - 1][j];
    }
  }
  for (j = 1; j <= c; j++) {
    for (i = 1; i <= r; i++) {
      dpc[i][j] = dpc[i - 1][j];
      if (ar[i - 1][j] == 1 && ar[i][j] == 1) {
        dpc[i][j]++;
      }
    }
  }
  for (j = 1; j <= c; j++) {
    for (i = 1; i <= r; i++) {
      dpc[i][j] += dpc[i][j - 1];
    }
  }
  cin >> q;
  int r1, c1, r2, c2;
  while (q--) {
    cin >> r1 >> c1 >> r2 >> c2;
    long long smr =
        dpr[r2][c2] - dpr[r2][c1] - dpr[r1 - 1][c2] + dpr[r1 - 1][c1];
    long long smc =
        dpc[r2][c2] - dpc[r1][c2] - dpc[r2][c1 - 1] + dpc[r1][c1 - 1];
    cout << (smr + smc) << "\n";
  }
  return 0;
}
