#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500;
char s[MAX_N + 2][MAX_N + 2];
int D[2][MAX_N + 1][MAX_N + 1];
int main() {
  int N, M;
  scanf("%d%d\n", &N, &M);
  for (int i = 0; i <= M; ++i) s[0][i] = '#';
  for (int i = 1; i <= N; ++i) {
    s[i][0] = '#';
    gets(s[i] + 1);
  }
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) {
      D[0][i][j] = D[0][i - 1][j] + D[0][i][j - 1] - D[0][i - 1][j - 1] +
                   (((s[i][j - 1] != '#')) & -(s[i][j] != '#'));
      D[1][i][j] = D[1][i - 1][j] + D[1][i][j - 1] - D[1][i - 1][j - 1] +
                   (((s[i - 1][j] != '#')) & -(s[i][j] != '#'));
    }
  int numQuery;
  scanf("%d", &numQuery);
  while (numQuery--) {
    int x, y, X, Y;
    scanf("%d%d%d%d", &x, &y, &X, &Y);
    y++;
    int SUM = D[0][X][Y] - D[0][x - 1][Y] - D[0][X][y - 1] + D[0][x - 1][y - 1];
    y--;
    x++;
    SUM += D[1][X][Y] - D[1][x - 1][Y] - D[1][X][y - 1] + D[1][x - 1][y - 1];
    printf("%d\n", SUM);
  }
  return 0;
}
