You are given a tree with vertices numbered from through . Every edge has weight or .
The tree distance between two vertices is the sum of the edge weights on their unique path.
Place every vertex at an integer coordinate on a line. Every pair of distinct vertices must satisfy both conditions below.
In particular, vertices at tree distance must still be placed at distinct coordinates.
The length of a placement is
Find the minimum possible value of .
The input is given in the following format:
For each test case, print the minimum possible length of a valid placement.
Each test case is given in the following format:
The -th edge connects and and has weight .