// Domino (C), by Errichto
// AC, O(wh + q)
#include<bits/stdc++.h>
using namespace std;
const int nax = 2005;
char sl[nax][nax];
// horizontal and vertical
int hor[nax][nax], ver[nax][nax];
int main() {
int w, h;
scanf("%d%d", &h, &w);
for(int y = 0; y < h; ++y) scanf("%s", sl[y]);
for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) {
hor[x+1][y+1] = hor[x][y+1] + hor[x+1][y] - hor[x][y];
ver[x+1][y+1] = ver[x][y+1] + ver[x+1][y] - ver[x][y];
if(sl[y][x] != '.') continue;
if(x != w - 1 && sl[y][x+1] == '.') ++hor[x+1][y+1];
if(y != h - 1 && sl[y+1][x] == '.') ++ver[x+1][y+1];
}
int q;
scanf("%d", &q);
while(q--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
--x1;--y1;
int ans = 0;
ans += hor[x2-1][y2] - hor[x1][y2] - hor[x2-1][y1] + hor[x1][y1];
ans += ver[x2][y2-1] - ver[x1][y2-1] - ver[x2][y1] + ver[x1][y1];
printf("%d\n", ans);
}
return 0;
}
Ly8gRG9taW5vIChDKSwgYnkgRXJyaWNodG8KLy8gQUMsIE8od2ggKyBxKQojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG5heCA9IDIwMDU7CmNoYXIgc2xbbmF4XVtuYXhdOwovLyBob3Jpem9udGFsIGFuZCB2ZXJ0aWNhbAppbnQgaG9yW25heF1bbmF4XSwgdmVyW25heF1bbmF4XTsKCmludCBtYWluKCkgewoJaW50IHcsIGg7CglzY2FuZigiJWQlZCIsICZoLCAmdyk7Cglmb3IoaW50IHkgPSAwOyB5IDwgaDsgKyt5KSBzY2FuZigiJXMiLCBzbFt5XSk7Cglmb3IoaW50IHkgPSAwOyB5IDwgaDsgKyt5KSBmb3IoaW50IHggPSAwOyB4IDwgdzsgKyt4KSB7CgkJaG9yW3grMV1beSsxXSA9IGhvclt4X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