DIY Planes
It is $2040$ and the University Park Airport is finally expanding! Instead of buying new planes, airline companies decided to let the students of Penn State build their planes to give them some real world experience. Unfortunately the lead student officer in charge lost the instruction sheet with the right order for constructing planes. As a result, you only have a list of pairs of parts (a b, where a must be attached to the plane before b) used to build the planes. You also know that changing the order while placing the parts would result in a different model being built. Help the students build a plane!
Input
The first line of input contains two integers $N,M$ ($1 \le N,M \le 10^4$) denoting $N$ number of parts given to you followed by $M$ pairs of parts in the list denoting the order. The following $M$ lines consist of parts $a_ i$ and $b_ i$ for every input line i.
Output
Output the string ’YES’ if there exists a unique order in which the plane can be built or ’NO’ if no plane can be built
| Sample Input 1 | Sample Output 1 |
|---|---|
5 5 4 1 0 3 3 1 4 2 2 0 |
YES |
| Sample Input 2 | Sample Output 2 |
|---|---|
6 7 0 2 3 5 4 2 1 3 2 1 3 4 0 1 |
NO |
