#include <bits/stdc++.h>
using namespace std;
int main() {
  int h = 2, w = 2;
  char map[502][502];
  int qmap[502][502];
  int i, j;
  cin >> h >> w;
  for (i = 1; i <= h; i++)
    for (j = 1; j <= w; j++) {
      scanf(" %c", &map[i][j]);
    }
  int cnt;
  int x, y;
  for (y = 1; y <= h; y++) {
    qmap[y][0] = 0;
    for (x = 1; x <= w; x++) {
      cnt = 0;
      if (map[y][x] == '.') {
        if (map[y + 1][x] == '.') {
          ++cnt;
        }
        if (map[y][x + 1] == '.') {
          ++cnt;
        }
      }
      qmap[y][x] = cnt + qmap[y][x - 1];
    }
  }
  int q;
  cin >> q;
  int r1, c1, r2, c2;
  for (i = 1; i <= q; i++) {
    cnt = 0;
    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    for (y = r1; y < r2; y++) {
      cnt += qmap[y][c2 - 1] - qmap[y][c1 - 1];
    }
    for (x = c1; x < c2; x++) {
      if (map[r2][x] == '.') {
        if (map[r2][x + 1] == '.') {
          ++cnt;
        }
      }
    }
    for (y = r1; y < r2; y++) {
      if (map[y][c2] == '.') {
        if (map[y + 1][c2] == '.') {
          ++cnt;
        }
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
