cho.sh
Notes
Loading...

Emergency Center

Time limit

1s

Memory limit

128 MB

Problem

A subway network consists of exactly one circular line and branch lines attached to stations on that circle. Each branch is a tree, and a station may have no branch attached. The whole network may therefore consist only of the circular line. The stations are numbered from 1 to N. Each track connects two stations and has a travel time. In this network, the number of stations is always equal to the number of tracks.

To support emergency response after an accident, emergency centers will be installed at two distinct stations. For a station, its emergency response time is the shortest travel time from that station to the nearer emergency center. Find two stations for the emergency centers so that the maximum emergency response time over all stations is as small as possible.

Input

The first line contains N, the number of stations and also the number of tracks. (3 <= N <= 50,000)

Each of the next N lines contains three positive integers u, v, and x describing one track. Stations u and v are directly connected by the track, and traveling through it takes x time. The value x is between 1 and 10,000, inclusive.

Output

On the first line, output the numbers of two distinct stations where the emergency centers will be installed, separated by a space. If there is more than one valid optimal answer, output any one of them.

On the second line, output the maximum emergency response time among all stations.