Undirected weighted tree is given. Find the length of the longest path. Find two vertices the distance between which is maximum.
The first line contains the number of vertices in the tree . The next lines describe the edges. Each line contains three integers: numbers of vertices connected with an edge (vertices are numbered from to ) and the weight of an edge.
Print the length of the longest path.