#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
int n, m, q;
int f[501][501];
char s[501][501];
int main() {
  cin >> n >> m;
  for (int i = (1), _e = (n); i <= _e; i++) {
    cin >> s[i] + 1;
  }
  for (int i = (1), _e = (n); i <= _e; i++) {
    int cnt = 0;
    for (int j = (1), _e = (m); j <= _e; j++) {
      if (s[i][j] == '#')
        f[i][j] = f[i - 1][j] + cnt;
      else if (s[i][j] == '.') {
        if (s[i][j - 1] == '.') cnt++;
        if (s[i - 1][j] == '.') cnt++;
        f[i][j] = cnt + f[i - 1][j];
      }
    }
  }
  cin >> q;
  for (int z = (1), _e = (q); z <= _e; z++) {
    int i1, j1, i2, j2, rx = 0;
    cin >> i1 >> j1 >> i2 >> j2;
    rx = f[i2][j2] - f[i1 - 1][j2] - f[i2][j1 - 1] + f[i1 - 1][j1 - 1];
    for (int j = (j1), _e = (j2); j <= _e; j++)
      if (s[i1][j] == '.' and s[i1 - 1][j] == '.') rx--;
    for (int i = (i1), _e = (i2); i <= _e; i++)
      if (s[i][j1] == '.' and s[i][j1 - 1] == '.') rx--;
    cout << rx << '\n';
  }
  return 0;
}
