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
import os
import sys
from io import BytesIO, IOBase
import heapq as h 
from bisect import bisect_left

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
import time
start_time = time.time()

import collections as col
import math, string
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
for each row, an array [0,1,0,0,1,...] where 1 means we can have a domino starting there
same for each col
then compute prefix sums
"""

def solve():
    N, M = getInts()
    grid = []
    for n in range(N):
        grid.append(getStr())
    rows = [[]]
    cols = [[]]
    for n in range(N):
        curr = 0
        tmp = [0]
        for m in range(M-1):
            if grid[n][m] == '.' and grid[n][m+1] == '.':
                curr += 1
            tmp.append(curr)
        tmp.append(curr)
        rows.append(tmp)
    for m in range(M):
        curr = 0
        tmp = [0]
        for n in range(N-1):
            if grid[n][m] == '.' and grid[n+1][m] == '.':
                curr += 1
            tmp.append(curr)
        tmp.append(curr)
        cols.append(tmp)
    for q in range(getInt()):
        r1, c1, r2, c2 = getInts()
        ans = 0
        for c in range(c1,c2+1):
            ans += cols[c][r2-1] - cols[c][r1-1]
        for r in range(r1,r2+1):
            ans += rows[r][c2-1] - rows[r][c1-1]
        print(ans)
    return

        
            
    
    
#for _ in range(getInt()):    
solve()