You are given a tree with nodes, where each edge has a positive cost. Let and be any two adjacent nodes. Define as the maximum cost of all paths (with no repeated nodes) whose first step goes from to . Define as the sum of for all adjacent to . Please compute the maximum value of among all nodes .
Input consists of several cases. Every case begins with the number of nodes , followed by edges, each one with two different nodes and the cost of the edge between them. Assume . The nodes are numbered starting at zero. Each cost is an integer number between 1 and 1000. The given graph is always a tree. The number of steps between any two nodes is never larger than 1000.
For every case, print the maximum , and how many nodes achieve such a value.
Input
2 0 1 100 3 1 0 10 1 2 20 4 1 0 10 1 2 20 3 1 30 6 0 2 20 1 2 50 2 3 100 3 4 30 3 5 40
Output
100 2 30 3 60 1 220 1