#Lutece0456. Find the Champion

Find the Champion

Migrated from Lutece 456 Find the Champion

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

We all know that in Mathematics, if A>BA>B and B>CB>C, then we can easily get A>CA>C, however, in actual contest, things may not turn out to be as easy as that!

For example, in the Allelujah Championship of Mathematics (ACM), there are three players left, the contest is a knock-out type. So they need 22 more matches to determine the final champion!

From the previous practice results we know that gongbaoa always beats kennethsnow, and kennethsnow will get a win on elfness for sure. However, when gongbaoa meets elfness, since elfness is a beautiful girl, gongbaoa always loses to her for some strange reasons. This can lead to a serious problem: Everyone has the chance to win the Competition!

If you are still confused, there's an easier explanation: If in the first round kennethsnow beat elfness, he will lose to gongbaoa, and the latter will be the champion. If in the first round gongbaoa beat kennethsnow, he will lose to elfness, and elfness will be the winner, still, kennethsnow has a chance to win, as long as gongbaoa loses to elfness in the first round. We call those three guys "potential champions".

Now, if there are NN people competing in ACM, of course we need at most N1N-1 matches to ditermine the champion. And for each round, we randomly select two players to have a match, the winner will get to the next round. We have some information about those players, that is to say, we can know some of the match result for sure.

To simplify the problem, we set a special rule to determion the champion for each match:

  1. If we have the direct information of that match, then the champion is determined for sure.
  2. If we don't have the direct information, but we can find a path from AA to BB, that is to say, if AA can beat A2A_2, and A2A_2 can beat A3A_3..., finally, there is a AkA_k who can beat BB, then we say there is a path from AA to BB. So, if there exists a path from AA to BB, but not a path from BB to AA, then we set AA as the champion.
  3. In other cases, any one of them has the chance to win.

Your task is simple: given the match information we currently have, please determine the number of "potential champions"

Input

The first line of the input is TT (no more than 100100), which stands for the number of test cases you need to solve. Then TT data sets follow.

For each dataset, the first line contains two numbers nn and mm, which stands for the number of nodes and edges. (0<n1000000 < n \leq 100000, 0m1000000 \leq m \leq 100000) Then mm lines follow, each line with 22 numbers uu and vv, (0u,v<n0\leq u,v < n, uvu\neq v) means that if uu meet vv in the match, then uu will win for sure.

Output

For each dataset, For each test case, first output Case #C: , where CC is the number of test case, from 11 to TT.Then print out a single number nn which is the number of "potential champions", for the next line you should output exact nn numbers which are the id of those people in sorted order, the numbers are seperated with a single space.

Samples

3
3 3
0 1
1 2
2 0
3 0
2 1
0 1
Case #1: 3
0 1 2
Case #2: 3
0 1 2
Case #3: 1
0

Note

  1. In the second case, since we have no information of those players, according to the rule above, all of them will be the champion, so the answer is 33.
  2. Don't ask me what does "Allelujah Championship of Mathematics" mean! I don't know either!

Resources

kennethsnow