They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.

Limak is a little polar bear who loves to play. He has recently got a rectangular grid with *h* rows and *w* columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Rows are numbered 1 through *h* from top to bottom. Columns are numbered 1 through *w* from left to right.

Also, Limak has a single domino. He wants to put it somewhere in a grid. A domino will occupy exactly two adjacent cells, located either in one row or in one column. Both adjacent cells must be empty and must be inside a grid.

Limak needs more fun and thus he is going to consider some queries. In each query he chooses some rectangle and wonders, how many way are there to put a single domino inside of the chosen rectangle?
The first line of the input contains two integers *h* and *w* (1 ≤ *h*, *w* ≤ 500) – the number of rows and the number of columns, respectively.

The next *h* lines describe a grid. Each line contains a string of the length *w*. Each character is either '.' or '#' — denoting an empty or forbidden cell, respectively.

The next line contains a single integer *q* (1 ≤ *q* ≤ 100 000) — the number of queries.

Each of the next *q* lines contains four integers *r*1<sub class="lower-index">*i*</sub>, *c*1<sub class="lower-index">*i*</sub>, *r*2<sub class="lower-index">*i*</sub>, *c*2<sub class="lower-index">*i*</sub> (1 ≤ *r*1<sub class="lower-index">*i*</sub> ≤ *r*2<sub class="lower-index">*i*</sub> ≤ *h*, 1 ≤ *c*1<sub class="lower-index">*i*</sub> ≤ *c*2<sub class="lower-index">*i*</sub> ≤ *w*) — the *i*-th query. Numbers *r*1<sub class="lower-index">*i*</sub> and *c*1<sub class="lower-index">*i*</sub> denote the row and the column (respectively) of the upper left cell of the rectangle. Numbers *r*2<sub class="lower-index">*i*</sub> and *c*2<sub class="lower-index">*i*</sub> denote the row and the column (respectively) of the bottom right cell of the rectangle.
A red frame below corresponds to the first query of the first sample. A domino can be placed in 4 possible ways.
5 8
....#..#
.#......
##.#....
##..#.##
........
4
1 1 2 3
4 1 4 1
1 2 4 5
2 5 5 8
4
0
10
15
7 39
.......................................
.###..###..#..###.....###..###..#..###.
...#..#.#..#..#.........#..#.#..#..#...
.###..#.#..#..###.....###..#.#..#..###.
.#....#.#..#....#.....#....#.#..#..#.#.
.###..###..#..###.....###..###..#..###.
.......................................
6
1 1 3 20
2 10 6 30
2 10 7 30
2 2 7 7
1 7 7 7
1 8 7 8
53
89
120
23
0
2
2 20
.#..................
....................
15
1 3 1 13
1 11 2 14
1 17 1 20
1 2 2 3
1 7 1 10
1 7 2 17
1 4 1 9
2 6 2 8
1 8 2 20
2 7 2 16
1 4 2 16
1 6 1 9
1 4 2 7
1 9 1 20
2 2 2 12
10
10
3
2
3
31
5
2
37
9
37
3
10
11
10
15 3
...
.#.
.#.
.#.
..#
...
.#.
.##
.#.
...
...
.##
..#
.#.
#.#
20
1 1 10 1
2 1 9 3
1 2 15 3
10 2 12 2
4 1 8 1
5 2 8 2
10 1 12 3
11 1 11 3
7 2 14 3
6 2 12 3
8 1 11 2
7 1 9 1
2 1 6 2
6 3 7 3
7 1 10 2
6 1 10 2
1 1 2 2
10 1 15 3
1 1 11 1
9 1 15 1
9
14
12
1
4
1
8
2
5
7
6
2
7
1
4
6
2
11
10
5
7 19
.##.#.#.#....#.#...
.#...##..........#.
..#.........#..#.#.
#.#....#....#......
.#.#.#.#....###...#
.....##.....#......
..........#.#..#.#.
10
2 2 3 10
4 10 5 16
3 3 6 12
2 12 6 14
5 1 5 19
3 11 3 13
4 10 5 17
1 13 4 19
5 3 5 17
4 15 7 19
15
10
43
8
5
1
13
24
4
19
1 1
.
1
1 1 1 1
0
1 1
#
1
1 1 1 1
0
from sys import maxsize, stdout, stdin,stderr
mod = int(1e9+7)
import sys
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return list(map(str,input().strip()))
def grid(r, c): return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop , heappush
import bisect
from itertools import groupby
from itertools import permutations as comb
def gcd(a,b): 
    while b:
        a %= b
        tmp = a
        a = b
        b = tmp
    
    return a
 
def lcm(a,b): 
    return a  // gcd(a, b) * b
 
def check_prime(n):
    for i in range(2, int(n ** (1 / 2)) + 1):
        if not n % i:
            return False
    return True

def nCr(n, r):
 
    return (fact(n) // (fact(r)
                * fact(n - r)))
 
# Returns factorial of n
def fact(n):
 
    res = 1
     
    for i in range(2, n+1):
        res = res * i
         
    return res
def primefactors(n):
    num=0
    
    while n % 2 == 0:
        num+=1
        n = n / 2
    
    for i in range(3,int(math.sqrt(n))+1,2):
         
    
        while n % i== 0:
            num+=1
            n = n // i
               
    
    if n > 2:
        num+=1
    return num
'''
def iter_ds(src):
    store=[src]
    while len(store):
        tmp=store.pop()
        if not vis[tmp]:
            vis[tmp]=True
            for j in ar[tmp]:
                store.append(j)
'''
def ask(a):
    print('? {}'.format(a),flush=True)
    n=I()
    
    return n


 
def dfs(i,p):
    
    a,tmp=0,0
    for j in d[i]:
        if j!=p:
            a+=1
            tmp+=dfs(j,i)
    
    if a==0:
        return 0
    
    return tmp/a + 1 
def primeFactors(n):
    l=[]
    
    while n % 2 == 0:
        l.append(2)
        n = n // 2
         

    if n > 2:
        l.append(n)
    return l

   
t = 1
for _ in range(t):
    h,w = lint()
    
    s=[S() for _ in range(h)]
    dp1 = [[0]*(w+1) for _ in range(h+1)]
    dp2 = [[0]*(w+1) for _ in range(h+1)]
    for i in range(1,h+1):
        for j in range(1,w+1):
            if j==1:
                continue

            elif i==1:
                
                if s[i-1][j-1]=='#':
                    dp1[i][j]=dp1[i][j-1]
                else:
                    if s[i-1][j-2]=='.':
                        dp1[i][j]=dp1[i][j-1]+1
                    else:
                        dp1[i][j]=dp1[i][j-1]
                
            else:
                if s[i-1][j-1]=='#':
                    dp1[i][j]=dp1[i-1][j]+dp1[i][j-1]-dp1[i-1][j-1]
                else:
                    tmp=0
                    if s[i-1][j-2]=='.':
                        tmp+=1
                    
                    dp1[i][j]=dp1[i-1][j]+dp1[i][j-1]-dp1[i-1][j-1]+tmp
            
    
    for i in range(1,h+1):
        for j in range(1,w+1):
            if i==1:
                continue
            elif j==1:
                if s[i-1][j-1]=='#':
                    dp2[i][j]=dp2[i-1][j]
                else:
                    if s[i-2][j-1]=='.':
                        dp2[i][j]=dp2[i-1][j]+1
                    else:
                        dp2[i][j]=dp2[i-1][j]
            else:
                if s[i-1][j-1]=='#':
                    dp2[i][j]=dp2[i-1][j]+dp2[i][j-1]-dp2[i-1][j-1]
                else:
                    tmp=0
                    
                    if s[i-2][j-1]=='.':
                        tmp+=1
                    dp2[i][j]=dp2[i-1][j]+dp2[i][j-1]-dp2[i-1][j-1]+tmp        
    
    
    q=I()
    for i in range(q):
        a,b,c,d=lint()
        ans=0
        ans+= (dp1[c][d] - (dp1[c][b] + dp1[a-1][d] - dp1[a-1][b]))
        ans+= (dp2[c][d] - (dp2[a][d] + dp2[c][b-1] - dp2[a][b-1]))
        print(ans)
            
        
    