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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

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≤ai,bi≤n; ai≠bi; 1≤li≤109) — the data about the I-th street. The chart isn't really associated. It is ensured that between any two crossing points, there is all things considered one street for every bearing. 

 

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.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY