Journey
题号:NC15338
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Mr.Frog wants to travel all over the country, and as we all know the country consists of N cities and M directed roads connecting these cities. The cities are numbered from 1 to N. The roads are numbered from 1 to M, the ith road connects the city Ui to Vi which means Mr.Frog can move to city Vi from city Ui.

Mr.Frog wants to travel all cities, and he can choose a city to start his trip casually and choose a city to end his trip casually. In order to avoid the boredom in the journey, Mr.Frog decides to make a plan that can help him arrive each city exactly once and pass through each road exactly once. Now give you the information of the cities and roads. Please tell Mr.Frog whether there exists a way that can satisfy his plan.

输入描述:

The first line contains an integer T, where T is the number of test cases. T test cases follow.
For each test case, the first line contains two integers N and M, where N is the number of cities, and M is the number of roads.

Then next M lines follow, the ith line contains two integers Ui and Vi, indicating there is a directed road from city Ui to city Vi.


• 1 ≤ T ≤ 105.
• 1 ≤ N ≤ 105.
• 0 ≤ M ≤ 105.
• 1 ≤ Ui,Vi ≤ N.
• the sum of N in all test cases doesn’t exceed 106.• the sum of M in all test cases doesn’t exceed 106.

输出描述:

For each test case, print a line containing “Case #x:”, where x is the test case number (starting from 1).
In the next line, print the city number in the order of his journey, if there is a way that can satisfy his plan; otherwise print “NO”.
示例1

输入

复制
2
4 3
1 2
2 3
3 4
4 2
1 2
3 4

输出

复制
Case #1:
1 2 3 4
Case #2:
NO

备注:

For the first case, Mr.Frog chooses city 1 to start his trip and travels in the order of 1, 2, 3, 4.
For the second case, there is no way that can satisfy his plan, so print “NO”.