HHAND - Hospital at Hands

no tags 

In a remote part of the Country, there lies a group of towns, quite far from any other areas. These towns are connected by a set of roads, having the property that there is exactly one path connecting any two towns, and every town is connected.

Apollo Hospitals Ltd. decides to invest in this area, and build some Hospitals. Their analyst has a monumental task ahead of him. His job is to find out a set of continuous towns, from among them, to build one hospital in each. The path connecting the first town to the last town in the set (which obviously passes through all the remaining ones) should not be more than length L, to avoid inconvenience to the visiting doctors. Also, the analyst has to make sure that his selection of target towns is such that the people of the area have to cover the least distance to reach the hospital closest to them.

Thus, the towns where Hospitals will be built have to be chosen keeping in mind that the sum of distances that people from each town will need to cover, in order to reach the Hospital closest to them, should be minimum.

You have to find this minimum sum.

Input

First line of input contains an integer T which is equal to the number of test cases. You are required to process all test cases. Each test case starts with 2 space separated integers N and L. N denotes the number of towns and L is the length of path connecting first and last town in the set. Next N-1 lines follow each contains two space separated integers a and b denoting a road between A and B. A and B are 0 based.

Output

Output consists of T lines. Ith line in the output corresponds to the minimum sum total of the distances of all the towns with the nearest hospital for the Ith test case.

Example

Input:
2
3 1
0 1
1 2
4 1
0 1
1 2
2 3

Output:
1
2

Constraints and Limits

T ≤ 30, n ≤ 10000, 0 < L ≤ 100



Added by:Ajay Somani
Date:2008-02-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:CodeCraft 08 Aryan-Gaurav,Ajay Somani