JZPTREE

Time Limit: 10000ms
Memory Limit: 655360KB
This problem will be judged on HDU. Original ID: 4625
64-bit integer IO format: %I64d      Java class name: Main

Description

There is a tree,there is a life.Can you solve this problem about tree?
Here we have a tree which has n vertices.
We define dist(u, v) as the number of edges on the path from u to v.
And for each vertices u , define Eu =
Give you the tree and k.
Print Ei for every vertices(from 1 to n).(mod 10007 for convenience).

Input

The first line contains integer T(1  T  5),denote the number of the test cases.
For each test cases,the first line contains two integers n,k(1<=n<=50000, 1<=k<=500).
Then next n-1 lines,each lines contains two integer a,b(1<=a, b<=n),denote there is an edge between a, b.

Output

For each test cases,print n lines,the i-th line contains Ei.

Sample Input

1
5 3
1 2
2 3
3 4
4 5

Sample Output

100
37
18
37
100

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .