SP2070 MINDIST - Minimum Distance

Description

Given an weighted tree, you are to find two nodes A and B of the tree(A and B needn't to be different), such that the length of the path between A and B is less than or equals to a given integer S, and the maximum distance from each node of the tree to this path is minimum.

Input Format

The first line of the input contains a single integer T, the number of test cases. T blocks follow. For each test case, the first line contains two space-separated integer N (1

Output Format

T lines, each contains a single integer denoted the minimum distance.