Cube World has N cities and N−1 bidirectional roads. Every pair of distinct cities is joined by a route, so the road network is a tree. Cities are numbered from 1 to N, roads are numbered from 1 to N−1, and road i has length li.
The ruler of Cube World is holding a festival. He picks M of the N−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 M 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 0.
For each test case, find that minimized maximum.
The first line contains an integer T (1≤T≤100), the number of test cases.
The first line of each test case contains two space separated integers N and M (2≤N≤2000, 1≤M≤N−1), where N is the number of cities and M is the number of roads to pick. The next N−1 lines describe the roads. The i-th of them contains three space separated integers ai, bi, li (1≤ai,bi≤N, ai=bi, 1≤li≤106), meaning that road i connects city ai and city bi and its length is li.
The sum of N over all test cases does not exceed 2000.
For each test case, print one line with the maximum length of a simple path over the picked roads, for a choice of M roads that makes this value as small as possible.
A simple path is a path that never repeats a city. It is a sequence of distinct cities c1,c2,…,cl such that for every i with 1≤i≤l−1 a road connects city ci and city ci+1. In this problem every such road has to be a picked road.