## Mock CCC '18 Contest 5 J5/S3 - Carol's Cute Chase

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 1G
Author:

Problem type

Having successfully passed his background check, Tudor is finally on his way to Google! Little does he know that Carol is attempting to surprise him by arriving there first.

Carol is currently in Canada and needs to sneak over to Google. This will require taking several flights.

Because Carol is flying Air Canada, she is sure that she will be accepted at all intermediate airports and eventually be able to arrive at Google. However, a recent law called The Last Endeavor recently passed, which allows Wicked Agents to Realistically Terminate Every flight that goes from one airport to another. This will cause mass load externally.

Carol is prepared for this contingency - if the TLE forces the WAs to RTE a given flight, is it still possible for her to fly AC to Google?

#### Input Specification

The first line of the input contains two space-separated integers, and .

Each of the next lines contains two space-separated integers, and , indicating that there are one-way flights from airport to .

You may assume that any given tuple appears at most once.

Carol starts at airport and wishes to get to airport .

#### Output Specification

Output lines.

On the th line, given that the th flight is impossible to take but all other flights are permissible, print YES if it is still possible for Carol to get to airport from airport . Print NO otherwise.

#### Sample Input

3 3
1 2
2 1
2 3

#### Sample Output

NO
YES
NO