Bus Lines

아직 제출이 없습니다시간 제한0.75초메모리 제한64 MB

문제

There are (n1)(n - 1) bidirectional streets connecting nn crossroads (numbered 11 to nn) in Byteozavodsk. There is only one way to travel between every pair of crossroads without going through any street more than once.

You are tasked with planning city's bus line routes. A bus line route starts and ends at a crossroad such that there is only one street that is incident with this crossroad. The starting crossroad must be different from the ending one.

Every street has a capacity: the number of bus lines that can pass through this street.

Calculate the maximum possible number of bus lines that can be arranged in Byteozavodsk. Not that it makes any sense, but there can be two bus lines that are connecting exactly the same pair of crossroads.

입력

The first line contains one integer zz, the number of test cases. Then zz test cases are described in the following way.

The first line of each test case description contains one integer nn (2n1052 \leq n \leq 10^5), the number of crossroads in Byteozavodsk. Each of the following (n1)(n - 1) lines describing city streets contains three integers aa, bb, cc (1a,bn1 \leq a, b \leq n, aba \neq b, 1c1061 \leq c \leq 10^6) meaning that a particular street connects crossroad aa with crossroad bb, and has a capacity of cc.

출력

For each test case, output a single line containing one integer: the maximum number of bus lines that can be arranged in Byteozavodsk.