시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB155545.455%

문제

Little Square has started jumping on trampolines from his school’s gym. In the gym there are R × C trampolines arranged in a rectangular grid with R rows and C columns. Each trampoline is either green or blue. There are exactly N green trampolines. Let (i, j) denote the trampoline in the ith row and jth column. We index the rows from 1 to R and the columns from 1 to C.

Little Square’s teacher has asked him to practice T gymnastics routines. The ith routine has the following rules:

  • The routine starts at trampoline (xistart, yistart).
  • The routine ends at trampoline (xistop, yistop).
  • If Little Square jumps on a green trampoline at position (i, j) then he may go to trampolines (i + 1, j) or (i, j + 1), as long as these are not outside the grid.
  • If Little Square jumps on a blue trampoline at position (i, j) then he may go to trampoline (i, j+1), as long as it is not outside the grid.

Little Square wants to know, for each routine, if it is possible to accomplish his teacher’s request.

입력

On the first line of the input you will find R, C and N. On the next N lines you will find the positions of the green trampolines. If a line contains integers a b then there is a green trampoline at position (a, b). On the next line you will find T. On the next T lines you will find the descriptions of the gymnastics routines. On the ith of these lines you will find xistart, yistart, xistop, yistop.

출력

Output T lines. The ith line should contain Yes if it possible to accomplish the ith routine, and No if it is not.

제한

  • 1 ≤ R, C ≤ 1,000,000,000
  • 1 ≤ N, T ≤ 200,000
  • 1 ≤ xistart, xistop ≤ R
  • 1 ≤ yistart, yistop ≤ C
  • The coordinates of green trampolines are pairwise distinct.

서브태스크 1 (23점)

  • 1 ≤ R, C, T ≤ 200

서브태스크 2 (20점)

  • 1 ≤ R, C ≤ 2,500
  • 1 ≤ T ≤ 4,000

서브태스크 3 (11점)

  • xistop - xistart = 1

서브태스크 4 (19점)

  • 1 ≤ T, N ≤ 5,000

서브태스크 5 (27점)

  • No additional constraints.

예제 입력 1

4 5 2
2 2
3 4
3
2 1 4 5
1 2 1 4
2 3 4 4

예제 출력 1

Yes
Yes
No

힌트

The trampolines are placed like so:

In the first routine Little Square can go on the following route: (2, 1) → (2, 2) → (3, 2) → (3, 3) → (3, 4) → (4, 4) → (4, 5).

In the second routine Little Square can go on the following route: (1, 2) → (1, 3) → (1, 4).

The third routine cannot be accomplished. No route exists from (2, 3) to (4, 4) that respects Little Square’s teacher’s rules.

채점 및 기타 정보

  • 예제는 채점하지 않는다.