405000: GYM101733 F Network Topology

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Network Topologytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

The Alexander's distributed computational system consists of n computers which are connected in a network with n - 1 wires. Each pair of computers is directly or indirectly (via other computers) connected by these wires.

Alexander is worried about the safety of the data in the system. He plans to add the extra HDDs into two storage computers. The distance between two computers is the minimum possible number of wires that is required to get data from one computer to the other. When Alexander picks two computers, for each computer in his network he computes the minimum possible distance to the storage. Unreliability of the whole network is equal to the maximum value of this minimum distance among all computers in the network.

Help Alexander and find two different computers which should be used to install additional hard drives in order to achieve minimum value of unreliability.

Input

The first input line contains one integer n (2 ≤ n ≤ 200 000), number of computers in the Alexander's system. Each of the next n - 1 lines contains two integers x y (1 ≤ x, y ≤ n, x ≠ y), the indices of computers connected by the direct connection.

Output

Print the indices of two different selected computers. If there are multiple correct solutions, print any of them.

ExamplesInput
3
1 2
2 3
Output
3 1
Input
6
1 2
3 2
2 4
4 5
4 6
Output
2 4

加入题单

算法标签: