#Q103. 「一本通 3.6 练习 2」嗅探器
「一本通 3.6 练习 2」嗅探器
Description
Original source: ZJOI 2004
In a military information warfare exercise, the Red Army successfully infiltrated the Blue Army's internal network. The Blue Army has two information centers. The Red Army plans to install a sniffer on an intermediate server to intercept all messages exchanged between the two information centers. However, the Blue Army's network is quite extensive, and there can be multiple paths for data packets to travel from one information center to another. Your task is to quickly determine on which intermediate server the sniffer should be installed to ensure that all data packets can be captured.
Input Format
The first line of the input file contains an integer , representing the number of servers in the Blue Army's network.
The following lines describe the topological structure of the Blue Army's network. Each line contains two integers and , indicating that there is a bidirectional connection between server and server . Server numbering starts from . A line with two s marks the end of the topological description. The next two integers and represent the IDs of the two central servers.
Output Format
Output the ID of the server. If there are multiple solutions, output the smallest ID. If no solution exists, output No solution.
Sample 1
5
2 1
2 5
1 4
5 3
2 3
5 1
0 0
4 2
1
Constraints & Notes