There are lines. Each line has an index between and . The slope of each line is negative, i.e. it goes from upper-left to lower-right.
There are queries. Each of them is in the format L R x y
, and you should output whether there is any line with index between and and the point is under it. If there is, then the answer is YES
, otherwise NO
.
As you know, any line splits an infinite plane into two regions. The point is under the line if that point is at the same region with point . If the point lies on the line it does not count.
Input Format
The first line contains , the number of lines. The following lines each contains two integers and that describes the line .
The next line contains , the number of queries. Each subsequent line contains 4 integers .
Output Format
For each query, output one line containing either YES
or NO
.
Constraints
(Number of lines)
(Number of queries)
Sample Input
2
-1 3
-2 -4
3
1 2 0 0
1 1 0 0
2 2 0 0
Sample Output
YES
YES
NO
Explanation
The image shows the two lines of the sample input.
Time Limits: C/C++ 1 sec, Java/C# 2 sec, other languages follow standard TL given in Environment