Define a neighbouring pair of cells in a matrix as a pair of cells (r_a,c_a) and (r_b,c_b) such that:
Define a spiral matrix as a matrix which satisfies the following conditions:
Given is a matrix of size n×m consisting of distinct positive integers. We are also given q queries. Each query defines a submatrix with corners (r_1,c_1) and (r_2,c_2). For each query, determine whether this submatrix is spiral.
The first line contains three integers n, m and q (1≤n,m≤2000, 1≤q≤106), denoting the size of the matrix and the number of queries, respectively.
Each of the next n lines contains m integers. The j-th integer on the i-th of these lines denotes the element a_i,j located in the i-th row and j-th column of the matrix (1≤a_i,j≤109). It is guaranteed that all elements are distinct.
Each of the next q lines contains four integers r_1, c_1, r_2, c_2 (1≤r_1≤r_2≤n, 1≤c_1≤c_2≤m), denoting the corners of a submatrix.
For each query, print the answer on a separate line. Print "YES" if the submatrix is spiral, or "NO" otherwise.