spoj#FPLAN. Field Plan
Field Plan
World Soccer Championship is coming soon and coach Yogi wants to prepare his team as well as possible. So he made up a strategy field plan for every player of the team. One plan describes a number of possible locations for the player on the field. Moreover, if Yogi wants the player to be able to move from one location A to another location B then the plan specifies the ordered pair (A,B). He is sure that his team will win if the players run over the field from one location to another using only moves of the plan.
Yogi tells every player to follow his plan and to start from a location that reaches every other location on the plan (by possibly multiple moves). However, it is quite difficult for some soccer players, simple minded as they are, to find a suitable starting location. Can you help every player to figure out the set of possible start locations?
Input
The first line gives the number of field plans. The input contains at most eleven field plans (what else?). Every plan starts with a line of two integers N and M, with 1 ≤ N ≤ 100000 and 1 ≤ M ≤ 100000, giving the number of locations and the number of moves. In the following M lines a plan specifies moves (A,B) by two white space separated integers 0 ≤ A,B < N. The plans are separated by a blank line.
Output
For every plan print out all possible starting locations, sorted increasingly and one per line. If there are no possible locations to start, print Confused. Print a blank line after each plan output.
Example
Input: 2 4 4 0 1 1 2 2 0 2 34 4 0 3 1 0 2 0 2 3
Output: 0 1 2
Confused