#include <bits/stdc++.h>
using namespace std;
char table[500][500];
int vert[500][500];
int hor[500][500];
int prefixvert[500][500];
int prefixhor[500][500];
int main() {
  int h = 0, w = 0, q = 0;
  int num = 0;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> table[i][j];
      if (i == 0) {
        vert[i][j] = 0;
      } else {
        if (table[i][j] == '#') {
          vert[i][j] = 0;
        } else {
          if (table[i - 1][j] == '#') {
            vert[i][j] = 0;
          } else {
            vert[i][j] = 1;
          }
        }
      }
      prefixvert[i][j] = vert[i][j];
      if (i > 0) prefixvert[i][j] += prefixvert[i - 1][j];
      if (j > 0) prefixvert[i][j] += prefixvert[i][j - 1];
      if (i > 0 && j > 0) prefixvert[i][j] -= prefixvert[i - 1][j - 1];
      if (j == 0) {
        hor[i][j] = 0;
      } else {
        if (table[i][j] == '#') {
          hor[i][j] = 0;
        } else {
          if (table[i][j - 1] == '#') {
            hor[i][j] = 0;
          } else {
            hor[i][j] = 1;
          }
        }
      }
      prefixhor[i][j] = hor[i][j];
      if (i > 0) prefixhor[i][j] += prefixhor[i - 1][j];
      if (j > 0) prefixhor[i][j] += prefixhor[i][j - 1];
      if (i > 0 && j > 0) prefixhor[i][j] -= prefixhor[i - 1][j - 1];
    }
  }
  cin >> q;
  int r1, c1, r2, c2;
  for (int t = 0; t < q; t++) {
    num = 0;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    r2--;
    c1--;
    c2--;
    if (r1 >= r2) {
      num = 0;
    } else {
      num = prefixvert[r2][c2];
      num -= prefixvert[r1][c2];
      if (c1 > 0) {
        num -= prefixvert[r2][c1 - 1];
        num += prefixvert[r1][c1 - 1];
      }
    }
    if (c1 >= c2) {
    } else {
      num += prefixhor[r2][c2];
      num -= prefixhor[r2][c1];
      if (r1 > 0) {
        num -= prefixhor[r1 - 1][c2];
        num += prefixhor[r1 - 1][c1];
      }
    }
    cout << num << endl;
  }
  return 0;
}
