City Lights Queries


You are looking at a square nighttime skyline represented as an n×nn \times n grid. Each cell is one window: a lit window is marked with *, and a dark window is marked with ..

You must answer qq queries. Each query gives the top-left corner (r1,c1)(r_1, c_1) and the bottom-right corner (r2,c2)(r_2, c_2) of a rectangle, and asks how many lit windows are inside that rectangle.

Input

The first line contains two integers nn and qq.

The next nn lines each contain a string of length nn describing the grid.

Each of the next qq lines contains four integers r1,c1,r2,c2r_1, c_1, r_2, c_2 describing an inclusive query rectangle.

Here, rr stands for row and cc stands for column, so each query is given as row column row column.

Rows and columns are numbered from 11 to nn, and the first pair (r1,c1)(r_1, c_1) is the top-left corner while the second pair (r2,c2)(r_2, c_2) is the bottom-right corner.

Output

For each query, output a single integer: the number of lit windows inside the requested rectangle.

Constraints

  • 1≤n≤10001 \le n \le 1000
  • 1≤q≤2⋅1051 \le q \le 2 \cdot 10^5
  • 1≤r1≤r2≤n1 \le r_1 \le r_2 \le n
  • 1≤c1≤c2≤n1 \le c_1 \le c_2 \le n

Example 1

Input 1
4 3
.*..
**..
..*.
***.
1 1 2 2
2 2 4 4
3 3 3 3
Output 1
3
4
1

Example 2

Input 2
5 3
*....
.*...
..*..
...*.
....*
1 1 5 5
2 1 4 3
1 5 5 5
Output 2
5
2
1

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.