By Guilherme Londe, PUC Goiás Brazil
Jersão, a famous wild animal tamer, wants to demonstrate his courage fronting a new fearsome creature that is causing panic to the people from Pequi's Graphland. This creature, which is a mutant jaguar, has a circulatory system that connects N vital organs through N-1 bidirectional vessels.
Jersão knows a special poison to kill the creature, but he has difficulties in finding the ideal organ to apply that. When the poison still have effect and hits an organ, this organ is damaged and the poison is propagated to each organ that is connected to it by a vessel. This poison also have a special property: whenever it travels a vessel the effect is reduced. The poison then is just able to damage the organs that are at a minimum distance of at most K steps from the organ it was first applied, taking each step as a vessel, and then the poison loses the effect. You may consider that there is poison enough and, wherever it stands, if the poison still have effect it always propagates.
Jersão knows the map of the circulatory system of the mutant jaguar and have just one dosage of the poison. Write a program that informs the number of organs that would be damaged if the poison were first applied in the organ i for all 1 ≤ i ≤ N .
The first line of the input contains two integers N and K (1 ≤ N, K ≤ 105), that represents, respectively, the amount of organs the circulatory system has and the number of steps the poison can travel until it loses the effect. Each of the next N-1 lines contains two integers ai and bi (1 ≤ ai, bi ≤ N, ai ≠ bi), that represents a vessel between the organs ai and bi.
The output consists in N lines, where the i-th line contains the number of organs that would be damaged if the poison were first applied to the i-th organ.
Input Sample | Output Sample |
10 2 |
7 |