跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1723. Rooks and Rectangles

    ID: 1729 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数据结构排序编程与模拟挑战难度共享题库Codeforces英文题面题目来源题面语言

Rooks and Rectangles

题目描述

E. Rooks and Rectangles
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarpus has a chessboard of size n×m, where k rooks are placed. Polycarpus hasn't yet invented the rules of the game he will play. However, he has already allocated q rectangular areas of special strategic importance on the board, they must be protected well. According to Polycarpus, a rectangular area of the board is well protected if all its vacant squares can be beaten by the rooks that stand on this area. The rooks on the rest of the board do not affect the area's defense. The position of the rooks is fixed and cannot be changed. We remind you that the the rook beats the squares located on the same vertical or horizontal line with it, if there are no other pieces between the square and the rook. Help Polycarpus determine whether all strategically important areas are protected.

Input

The first line contains four integers n, m, k and q (1≤n,m≤100000, 1≤k,q≤200000) − the sizes of the board, the number of rooks and the number of strategically important sites. We will consider that the cells of the board are numbered by integers from 1 to n horizontally and from 1 to m vertically. Next k lines contain pairs of integers "x y", describing the positions of the rooks (1≤xn, 1≤ym). It is guaranteed that all the rooks are in distinct squares. Next q lines describe the strategically important areas as groups of four integers "x1 y1 x2 y2" (1≤x1x2n, 1≤y1y2m). The corresponding rectangle area consists of cells (x,y), for which x1xx2, y1yy2. Strategically important areas can intersect of coincide.

Output

Print q lines. For each strategically important site print "YES" if it is well defended and "NO" otherwise.

Examples
Input
4 3 3 3
1 1
3 2
2 3
2 3 2 3
2 1 3 3
1 2 2 3
Output
YES
YES
NO
Note

Picture to the sample: For the last area the answer is "NO", because cell (1,2) cannot be hit by a rook.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1269 题。保留原作者与原赛事署名。