There are q vehicles that may just drive along those streets. The I-th vehicle begins at crossing point vi and has an odometer that starts at si, increases for every mile driven, and resets to 0 at whatever point it arrives at ti. Phoenix has been entrusted to drive vehicles along certain streets (conceivably none) and return them to their underlying crossing point with the odometer showing 0. For every vehicle, if it's
Correct answer will be upvoted else downvoted.
There are q vehicles that may just drive along those streets. The I-th vehicle begins at crossing point vi and has an odometer that starts at si, increases for every mile driven, and resets to 0 at whatever point it arrives at ti. Phoenix has been entrusted to drive vehicles along certain streets (conceivably none) and return them to their underlying crossing point with the odometer showing 0.
For every vehicle, if it's not too much trouble, find in case this is conceivable.
A vehicle might visit a similar street or crossing point a discretionary number of times. The odometers don't quit counting the distance subsequent to resetting, so odometers may likewise be reset a self-assertive number of times.
Input
The primary line of the input contains two integers n and m (2≤n≤2⋅105; 1≤m≤2⋅105) — the number of crossing points and the number of streets, individually.
Every one of the following m lines contain three integers computer based intelligence, bi, and li (1≤
The following line contains an integer q (1≤q≤2⋅105) — the number of vehicles.
Every one of the following q lines contains three integers vi, si, and ti (1≤vi≤n; 0≤si<ti≤109) — the underlying convergence of the I-th vehicle, the underlying number on the I-th odometer, and the number at which the I-th odometer resets, individually.
Output
Print q replies. In the event that the I-th vehicle's odometer might be reset to 0 by passing through certain streets (conceivably none) and getting back to its beginning convergence vi, print YES. In any case, print NO.
Step by step
Solved in 3 steps with 1 images