
ZOJ Problem Set  4045
Ezio learned a lot from his uncle Mario in Villa Auditore. He also made some contribution to Villa Auditore. One of the contribution is dividing it into many small districts for convenience of management. If one district is too big, person in control of this district would feel tiring to keep everything in order. If one district is too small, there would be too many districts, which costs more to set manager for each district. There are $n$ rooms numbered from 1 to $n$ in Villa Auditore and $(n1)$ corridors connecting them. Let's consider each room as a node and each corridor connecting two rooms as an edge. By coincidence, Villa Auditore forms a tree. Ezio wanted the size of each district to be exactly $k$, which means there should be exactly $k$ rooms in one district. Each room in one district should have at least one corridor directly connected to another room in the same district, unless there are only one room in this district (that is to say, the rooms in the same district form a connected component). It's obvious that Villa Auditore should be divided into $\frac{n}{k}$ districts. Now Ezio was wondering whether division can be done successfully. InputThere are multiple test cases. The first line of the input contains an integer $T$ (about 10000), indicating the number of cases. For each test case: The first line contains two integers $n$, $k$ ($1 \le n \le 10^5$, $1 \le k \le n$), indicating the number of rooms in Vally Auditore and the number of rooms in one district. The following $(n  1)$ lines each contains two integers $a_i$, $b_i$ ($1 \le a_i, b_i \le n$), indicating a corrider connecting two rooms $a_i$ and $b_i$. It's guaranteed that:
OutputFor each test case:
Please, DO NOT output extra spaces at the end of each line, or your answer will be considered incorrect! Sample Input3 4 2 1 3 3 2 1 4 6 3 1 3 1 4 1 6 2 5 5 1 8 4 1 2 2 3 2 4 1 5 5 6 5 7 5 8 Sample OutputYES 1 4 2 3 NO YES 4 3 2 1 5 6 7 8 Author: ZHANG, Yuan Source: ZOJ Monthly, June 2018 