#include <bits/stdc++.h>
using namespace std;
int val[512][512], val2[512][512];
int main() {
  int i, j, r1, r2, c1, c2, h, w, q;
  char ar[512][512];
  while (scanf("%d%d", &h, &w) == 2) {
    memset(val, 0, sizeof(val));
    memset(val2, 0, sizeof(val2));
    getchar();
    for (i = 1; i <= h; i++) {
      for (j = 1; j <= w; j++) {
        scanf("%c", &ar[i][j]);
      }
      getchar();
    }
    for (i = 1; i <= h; i++) {
      for (j = 1; j <= w; j++) {
        if (ar[i][j] == '.' && ar[i][j - 1] == '.' && j > 1)
          val[i][j] = val[i][j - 1] + 1;
        else
          val[i][j] = val[i][j - 1];
        if (ar[i][j] == '.' && ar[i - 1][j] == '.' && i > 1)
          val2[i][j] = val2[i - 1][j] + 1;
        else
          val2[i][j] = val2[i - 1][j];
      }
    }
    int res = 0;
    scanf("%d", &q);
    for (i = 1; i <= q; i++) {
      res = 0;
      scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
      for (j = r1; j <= r2; j++) {
        res += (val[j][c2] - val[j][c1]);
      }
      for (j = c1; j <= c2; j++) {
        res += (val2[r2][j] - val2[r1][j]);
      }
      printf("%d\n", res);
    }
  }
  return 0;
}
