PivotOJ

Mi Teleférico

시간 제한: 2000ms메모리 제한: 2048MB출처: JOI 2024-2025 본선BOJ 33726

문제

La Paz, the capital city of Bolivia, is famous as a tourist spot and for an aerial cable car called Mi Teleférico. You are now visiting La Paz for sightseeing, and you want to visit as many sightseeing places as possible. In this task, we consider the following simplified situation.

There are NN aerial cable car stations in La Paz, numbered from 11 to NN in ascending order of altitude. There are MM one-way lines, numbered from 11 to MM. There are PP aerial cable car companies, numbered from 11 to PP. Each line is managed by a single company. Line ii (1 &le; i &le; M) is operated from station AiA_i to station BiB_i, and is managed by the company CiC_i. Here, the line always runs from the lower altitude station to the higher altitude station. In other words, Ai<BiA_i < B_i holds.

The Bureau of transportation of La Paz issued unlimited ride passes for convenience. Each ride pass contains 22 integers ll, rr, which satisfy 1 &le; l &le; r &le; P. The pass enables the possessor to ride lines, which are managed by any one of company l,l+1,,rl, l + 1, \dots ,r. In other words, for an integer ii which satisfies 1 &le; i &le; M, the pass enables the possessor to ride line ii when l &le; C_i &le; r holds. It is possible to use a single pass for several lines. Let a ride pass (l,r)(l,r) denote this ride pass.

Now, QQ tourists, numbered from 11 to QQ, visit La Paz. Tourist jj (1 &le; j &le; Q) has a ride pass (Lj,Rj)(L_j, R_j) and XjX_j boliviano cash.

Each tourist’s goal is to ensure that no station cannot be travelled from station 11, using only lines that can be ridden with the ride pass he or she has. Tourist jj (1 &le; j &le; Q) can exchange his or her ride pass described in the following process to achieve their goal. Here, each tourist can exchange at most once.

  1. He or she chooses 22 integers ll', rr', which satisfy 1 &le; l' &le; r' &le; P.
  2. He or she exchanges a ride pass (Lj,Rj)(L_j, R_j) for a ride pass (l,r)(l', r'). It costs |L_j &minus; l'| + |R_j &minus; r'| boliviano as a fee.

Your purpose is to determine, for each tourist, whether or not he or she can achieve his or her goal within the cash he or she has.

Write a program which, given information about stations, lines, and tourists, determines whether or not he or she can achieve his or her goal within the cash he or she has for each tourist.

입력

Read the following data from the standard input.

NN MM PP

A1A_1 B1B_1 C1C_1

A2A_2 B2B_2 C2C_2

\vdots

AMA_M BMB_M CMC_M

QQ

L1L_1 R1R_1 X1X_1

L2L_2 R2R_2 X2X_2

\vdots

LQL_Q RQR_Q XQX_Q

출력

Write QQ lines to the standard output. On the jj-th line (1 &le; j &le; Q), output Yes if tourist jj can achieve his or her goal, and No otherwise.

예제

예제 1

입력
4 6 10
1 2 3
2 4 7
1 2 6
2 3 5
3 4 2
3 4 8
4
3 7 0
5 6 0
3 4 0
1 9 0
출력
Yes
No
No
Yes

예제 2

입력
4 6 10
1 2 3
2 4 7
1 2 6
2 3 5
3 4 2
3 4 8
3
5 6 10
3 4 1
7 8 3
출력
Yes
No
Yes

예제 3

입력
3 1 1000000000
1 2 6
1
1 1000000000 1000000000
출력
No

예제 4

입력
5 9 2000
2 3 1814
2 3 457
1 2 1226
3 4 1354
1 5 1050
1 2 1725
2 3 1383
1 5 1626
1 4 1795
5
850 1872 128
82 428 1217
487 924 573
1639 1926 202
202 420 25
출력
Yes
Yes
Yes
Yes
No
코드를 제출하려면 로그인하세요.