#K71982. Submatrix All Zeros Checker

    ID: 33652 Type: Default 1000ms 256MiB

Submatrix All Zeros Checker

Submatrix All Zeros Checker

Given a binary matrix with elements '0' and '1', and multiple queries, each query specifying a submatrix by its top-left \( (R_1, C_1) \) and bottom-right \( (R_2, C_2) \) coordinates, determine for each query if the submatrix contains only zeros.

Formally, for each query, you need to check if all elements in the submatrix \[ S = \{ matrix[i][j] \mid R_1 \le i \le R_2,\; C_1 \le j \le C_2 \} \] are equal to '0'.

Output "YES" if the submatrix contains only '0's, otherwise output "NO".

inputFormat

The first line contains two integers \( N \) and \( M \), representing the number of rows and columns of the matrix.

The next \( N \) lines each contain \( M \) space-separated characters (each being '0' or '1') representing the matrix.

The following line contains an integer \( Q \), denoting the number of queries.

Each of the next \( Q \) lines contains four integers \( R_1, C_1, R_2, C_2 \), representing a query for the submatrix.

outputFormat

For each query, output a single line containing "YES" if the specified submatrix contains only '0's; otherwise, output "NO".

## sample
1 1
0
1
1 1 1 1
YES