#include <bits/stdc++.h>
using namespace std;
const int MAX = 514;
int mat[MAX][MAX];
int aib[MAX][MAX];
int n, m;
int dx[] = {1, 0};
int dy[] = {0, 1};
inline int inside(int x, int y) {
  return x <= n and y <= m and x >= 1 and y >= 1;
}
int jos[MAX][MAX];
int dreapta[MAX][MAX];
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      char c;
      cin >> c;
      if (c == '#') ++mat[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int k = 0; k <= 1; ++k) {
        if (inside(i + dx[k], j + dy[k])) {
          if (mat[i][j] == 0 and mat[i + dx[k]][j + dy[k]] == 0) {
            aib[i][j]++;
            if (k == 0) {
              jos[i][j]++;
            } else {
              dreapta[i][j]++;
            }
          }
        }
      }
      aib[i][j] += aib[i - 1][j];
      aib[i][j] += aib[i][j - 1];
      aib[i][j] -= aib[i - 1][j - 1];
      jos[i][j] += jos[i][j - 1];
      dreapta[i][j] += dreapta[i - 1][j];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int dr = dreapta[c][d] - dreapta[a - 1][d];
    int jj = jos[c][d] - jos[c][b - 1];
    cout << aib[c][d] - aib[c][b - 1] - aib[a - 1][d] + aib[a - 1][b - 1] - dr -
                jj
         << '\n';
  }
  return 0;
}
