The festival must go on

No attempts yetTime limit1sMemory limit256 MB

Problem

Cube World has NN cities and N1N-1 bidirectional roads. Every pair of distinct cities is joined by a route, so the road network is a tree. Cities are numbered from 11 to NN, roads are numbered from 11 to N1N-1, and road ii has length lil_i.

The ruler of Cube World is holding a festival. He picks MM of the N1N-1 roads and runs one event on each picked road, such as a car parade or a sports match. The transport ministry complained that traffic would be paralysed, so the ruler decided to keep the disruption small. Among all ways to pick MM roads, he takes one that minimizes the maximum length of a simple path that uses only picked roads. The length of a path is the sum of the lengths of the roads on it, and a path that stays in one city has length 00.

For each test case, find that minimized maximum.

Input

The first line contains an integer TT (1T1001 \le T \le 100), the number of test cases.

The first line of each test case contains two space separated integers NN and MM (2N20002 \le N \le 2000, 1MN11 \le M \le N-1), where NN is the number of cities and MM is the number of roads to pick. The next N1N-1 lines describe the roads. The ii-th of them contains three space separated integers aia_i, bib_i, lil_i (1ai,biN1 \le a_i, b_i \le N, aibia_i \ne b_i, 1li1061 \le l_i \le 10^6), meaning that road ii connects city aia_i and city bib_i and its length is lil_i.

The sum of NN over all test cases does not exceed 20002000.

Output

For each test case, print one line with the maximum length of a simple path over the picked roads, for a choice of MM roads that makes this value as small as possible.

Note

A simple path is a path that never repeats a city. It is a sequence of distinct cities c1,c2,,clc_1, c_2, \dots, c_l such that for every ii with 1il11 \le i \le l-1 a road connects city cic_i and city ci+1c_{i+1}. In this problem every such road has to be a picked road.