Problem D
One-Way Roads
In the ACM kingdom, there are
Input
The first line of each test case consists of two integers,
Output
If it is impossible, output a single line NO. Otherwise, output YES on the first line, followed by
Sample Input 1 | Sample Output 1 |
---|---|
3 3 1 2 2 3 1 3 |
YES 1 3 2 1 3 2 |
Sample Input 2 | Sample Output 2 |
---|---|
4 3 1 2 1 3 1 4 |
NO |
Sample Input 3 | Sample Output 3 |
---|---|
4 5 1 2 2 3 4 3 1 4 2 4 |
YES 1 4 2 1 2 4 3 2 4 3 |