Code Submission Evaluation System Login

CSES Problem Set

Forest Queries


Task | Statistics


CSES - Forest QueriesCSES - Forest Queries

Time limit:1.00 s Memory limit:512 MB

You are given an $n \times n$ grid representing the map of a forest. Each square is either empty or contains a tree. Your task is to process $q$ queries of the form: how many trees are inside a given rectangle in the forest?

Input

The first input line has two integers $n$ and $q$: the size of the forest and the number of queries.

Then, there are $n$ lines describing the forest. Each line has $n$ characters: . is an empty square and * is a tree.

Finally, there are $q$ lines describing the queries. Each line has four integers $y_1$, $x_1$, $y_2$, $x_2$ corresponding to the corners of a rectangle.

Output

Print the number of trees inside each rectangle.

Constraints
Example

Input:
4 3
.*..
*.**
**..
****
2 2 3 4
3 1 3 1
1 1 4 4


Output:
3
1
10