IntermediateRating 1400
The Extra Cable
A network started as a tree on n computers; then one extra cable was added, creating exactly one loop. The cables are listed in the order they were laid. Print the last cable in the list that you could remove so the network becomes a tree again.
Input
n; then n lines 'u v'.
Output
Two integers.
Sample 1
Input
3 1 2 1 3 2 3
Output
2 3
Sample 2
Input
5 1 2 2 3 3 4 1 4 1 5
Output
1 4
Output appears here