| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 46 | 38 | 33 | 86.842% |
It has happened! You found a match! Excitedly, your match Hannah and you have decided to have a morning stroll together. Since the two of you live in different cities, you decide to meetup at a train station.
Getting to your respective cities' train station is no problem. However, the ongoing renovations of the national train network heavily impact the available connections. Some of them are not available at all, and some others are only one-way. This makes it uncertain whether you can meet up at all.
Figure H.1: Visualization of the third sample. Hannah starts from station $4$, and you start from station $1$. You can both reach station $3$ for your meet-up.
You have found a list of the available train connections online. A train station is suitable for your meet-up if both Hannah and you can reach it. Determine whether there is a suitable train station or whether it is necessary to move the morning stroll to another day.
The input consists of:
It is guaranteed that no train connection is listed multiple times.
If no suitable train station exists, output "no".
Otherwise, output "yes", followed by the train station. If there are multiple valid solutions, you may output any one of them.
3 2 1 3 2 3 1 2
yes 3
3 2 2 1 2 3 1 3
no
4 4 1 2 2 1 2 3 4 3 1 4
yes 3