Frieren is analyzing a magic barrier, whose strength at specific points can be represented as a 2D grid, , with
rows,
columns, and unique values. Specifically, the strength
of the barrier on the
row and
column is
. She asks you
questions in the form of
and your task for each of them is to determine whether
exists in the
inclusive rectangle formed by
and
.
Note: Fast input is highly recommended for this problem. Also, Python users should submit with PyPy as it is significantly faster.
Constraints
All values of are unique.
Subtask 1 [15%]
Subtask 2 [85%]
Input Specification
The first line contains integers,
,
, and
.
The next lines contain
integers each, representing the barrier strength
.
The next lines contain
integers each,
.
Output Specification
For each question, output yes
if the for that question exists in the given rectangle and
no
otherwise.
Sample Input 1
3 3 3
1 7 11
10 5 9
4 3 2
10 1 1 1 2
3 2 2 3 3
100 2 2 3 3
Sample Output 1
no
yes
no
Explanation for Sample Output 1
The rectangle for the first question is shown in blue. is not inside it.
The rectangle for the second question is shown in yellow. is inside it.
The rectangle for the third question is shown in yellow. is not inside it (it's not even in the grid).
Sample Input 2
2 3 2
1 2 3
4 5 6
1 1 1 1 1
1 2 2 2 3
Sample Output 2
yes
no
Comments