问题 A: A boring problem

文件提交:无需freopen 内存限制:256 MB 时间限制:10.000 S
评测方式:普通裁判 命题人:
提交:20 解决:3

题目描述

Bessie has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If Si,j is 1, the square at the i-th row and j-th column is blue; if Si,j is 0, the square is white. For every pair of two blue square a and b, there is at most one path that starts from a, repeatedly proceeds to an adjacent (side by side) blue square and finally reaches , without traversing the same square more than once.


Farmer John, a very boring man, gives 
Q boring queries to Bessie. The 
i-th query consists of four integers 


 and 
 and asks her the following: when the rectangular region of the grid bounded by (and including) the 
-th row, xi,2-th row, yi,1-th column and yi,2-th column is cut out, how many connected components consisting of blue squares there are in the region?

输入

The input is given from Standard Input in the following format:

$N \qquad M \qquad Q$

$S_{1,1}..S_{1,M}$

....

$S_{N,1}..S_{N,M}$

$x_{1,1} \quad y_{1,1} \quad x_{1,2} \quad y_{1,2} $

...

$x_{Q,1} \quad y_{Q,1} \quad x_{Q,2} \quad y_{Q,2}$


输出

For each query, print the number of the connected components consisting of blue squares in the region.

样例输入

3 4 4
1101
0110
1101
1 1 3 4
1 1 3 1
2 2 3 4
1 2 2 4

样例输出

3
2
2
2

提示

In the first query, the whole grid is specified. There are three components consisting of blue squares, and thus 3 should be printed.

In the second query, the region within the red frame is specified. There are two components consisting of blue squares, and thus 2 should be printed. Note that squares that belong to the same component in the original grid may belong to different components.


Constraints


  • 1Q200000
  • Si,j is either 0 or 1.
  • Si,j satisfies the condition explained in the statement.
  • 1xi,1xi,2N(1iQ)
  • 1yi,1yi,2M(1iQ)