Mi Teleférico
시간 제한2초메모리 제한2048 MB
각 관광객이 예산 안에서 회사 구간 패스를 다른 구간으로 바꿔 1번 역에서 모든 역에 도달할 수 있는지 판정한다.
문제
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 aerial cable car stations in La Paz, numbered from to in ascending order of altitude. There are one-way lines, numbered from to . There are aerial cable car companies, numbered from to . Each line is managed by a single company. Line () is operated from station to station , and is managed by the company . Here, the line always runs from the lower altitude station to the higher altitude station. In other words, holds.
The Bureau of transportation of La Paz issued unlimited ride passes for convenience. Each ride pass contains integers , , which satisfy . The pass enables the possessor to ride lines, which are managed by any one of company . In other words, for an integer which satisfies , the pass enables the possessor to ride line when holds. It is possible to use a single pass for several lines. Let a ride pass denote this ride pass.
Now, tourists, numbered from to , visit La Paz. Tourist () has a ride pass and boliviano cash.
Each tourist’s goal is to ensure that no station cannot be travelled from station , using only lines that can be ridden with the ride pass he or she has. Tourist () can exchange his or her ride pass described in the following process to achieve their goal. Here, each tourist can exchange at most once.
- He or she chooses integers , , which satisfy .
- He or she exchanges a ride pass for a ride pass . It costs 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.
출력
Write lines to the standard output. On the -th line (), output Yes if tourist can achieve his or her goal, and No otherwise.
제한
- .
- .
- .
- ().
- ().
- .
- ().
- ().
- Given values are all integers.