/*
author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
bool grid[1001][1001];
int dp[1001][1001];
void build_dp(int n, int m)
{
dp[0][0] = dp[1][0] = dp[0][1] = 0;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
dp[i][j] = grid[i][j] + dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1];
}
}
int getDP(int x, int y)
{
return dp[x][y];
}
int query(int x1, int y1, int x2, int y2)
{
return getDP(x2,y2) - getDP(x2,y1-1) - getDP(x1-1,y2) + getDP(x1-1,y1-1);
}
int main() {
fast_io;
int n,q;
cin >> n >> q;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
char ch;
cin >> ch;
if(ch == '*')
grid[i][j] = 1;
else grid[i][j] = 0;
}
}
build_dp(n,n);
while(q--)
{
int x1,x2,y1,y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << query(x1,y1,x2,y2) << '\n';
}
return 0;
}
LyoKICAgIGF1dGhvcjoga2FydGlrODgwMAoqLwojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZyKGEsYikgZm9yKGxsIGkgPSBhOyBpIDwgYjsgaSsrKQojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgaW5mICgxTEw8PDYwKQojZGVmaW5lIGFsbCh4KSAoeCkuYmVnaW4oKSwgKHgpLmVuZCgpCiNkZWZpbmUgcHJEb3VibGUoeCkgY291dCA8PCBmaXhlZCA8PCBzZXRwcmVjaXNpb24oMTApIDw8IHgKI2RlZmluZSB0cmlwbGV0IHBhaXI8bGwscGFpcjxsbCxsbD4+CiNkZWZpbmUgZmFzdF9pbyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKE5VTEwpCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpib29sIGdyaWRbMTAwMV1bMTAwMV07CmludCBkcFsxMDAxXVsxMDAxXTsKCnZvaWQgYnVpbGRfZHAoaW50IG4sIGludCBtKQp7CiAgICBkcFswXVswXSA9IGRwWzFdWzBdID0gZHBbMF1bMV0gPSAwOwoKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gbjsgaisrKQogICAgICAgICAgICBkcFtpXVtqXSA9IGdyaWRbaV1bal0gKyBkcFtpXVtqLTFdICsgZHBbaS0xXVtqXSAtIGRwW2ktMV1bai0xXTsKICAgIH0KfQoKaW50IGdldERQKGludCB4LCBpbnQgeSkKewogICAgcmV0dXJuIGRwW3hdW3ldOwp9CgppbnQgcXVlcnkoaW50IHgxLCBpbnQgeTEsIGludCB4MiwgaW50IHkyKQp7CiAgICByZXR1cm4gZ2V0RFAoeDIseTIpIC0gZ2V0RFAoeDIseTEtMSkgLSBnZXREUCh4MS0xLHkyKSArIGdldERQKHgxLTEseTEtMSk7Cn0KCmludCBtYWluKCkgewogICBmYXN0X2lvOwogICBpbnQgbixxOwogICBjaW4gPj4gbiA+PiBxOwoKICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgIHsKICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gbjsgaisrKQogICAgICAgewogICAgICAgICAgIGNoYXIgY2g7CiAgICAgICAgICAgY2luID4+IGNoOwogICAgICAgICAgIGlmKGNoID09ICcqJykKICAgICAgICAgICAgICAgIGdyaWRbaV1bal0gPSAxOwogICAgICAgICAgIGVsc2UgZ3JpZFtpXVtqXSA9IDA7CiAgICAgICB9CiAgIH0KCiAgIGJ1aWxkX2RwKG4sbik7CgogICB3aGlsZShxLS0pCiAgIHsKICAgICAgICAgICAgaW50IHgxLHgyLHkxLHkyOwogICAgICAgICAgICBjaW4gPj4geDEgPj4geTEgPj4geDIgPj4geTI7CiAgICAgICAgICAgIGNvdXQgPDwgcXVlcnkoeDEseTEseDIseTIpIDw8ICdcbic7CiAgIH0KICAgcmV0dXJuIDA7Cn0K