Sunset got a map of an abandoned gold mine in the border town. The map shows that the gold mine consists of n rooms connected by n−1 bidirectional tunnels, forming a tree structure. The map is so strange that on the i-th tunnel, there are two numbers a_i and b_i. The only thing Sunset knows is that there are exactly k tunnels whose lengths are taken from a while the lengths of other n−k−1 tunnels are taken from b.
Tomorrow Sunset will explore that gold mine. He is afraid of getting lost in the gold mine, so can you please tell him the diameter of the gold mine if he is lucky enough? In other words, please calculate the minimum possible length of the diameter from the information Sunset has.
The first line contains a single integer T (1≤T≤10,000), the number of test cases. For each test case:
The first line contains two integers n and k (2≤n≤20,000, 0≤k≤n−1, k≤20) denoting the number of rooms and the parameter k.
Each of the following n−1 lines contains four integers u_i, v_i, a_i, b_i (1≤u_i,v_i≤n, u_i=v_i, 1≤a_i,b_i≤109) denoting a bidirectional tunnel between the u_i-th room and the v_i-th room, the length of which is either a_i or b_i.
It is guaranteed that the sum of all n is at most 200,000.
For each test case, output a single line containing an integer: the minimum possible length of the diameter.