#P7870. Tree Cutting
Tree Cutting
Tree Cutting
Problem Description
Given a tree (connected undirected graph with vertexes and edges), you are required to delete as few vertexes as possible such that the remaining graph is still a tree and its diameter shall not exceed . The diameter of a tree is the length of its longest path.
Input
The first line contains one positive integer (), denoting the number of test cases. For each test case: The first line of the input contains two integers . Each of the following lines contains two integers , indicating that there is an edge connecting vertex and in the tree.
Output
For each test case: You should just output one integer indicating the number of vertexes to be deleted.
Sample Input
1
10 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
Sample Output
4
Source
2020 Multi-University Training Contest 10