You have a tree consisting of n vertices. You want to color each vertex of the tree in one of the k colors such that for any pair of vertices having same color, all the vertices belonging to the path joining them should also have same color. In other words, for any two vertices u, v with same color, all the vertices in the path joining them should also have color same as that of the u (or same as v, as u and v have same color). 

Find out possible number of ways in which you can color the tree satisfying the above property. As the answer could be large, print your answer modulo 109 + 7.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
For each test case, first line contains two space separated integers n, k denoting number of vertices in the tree and total number of colors, respectively
Each of the next n - 1 lines contain two space separated integers ui, vi, denoting that there is an edge between vertices ui and vi in the tree.

-----Output-----
For each test case, output a single line corresponding to number of ways of coloring the tree.

-----Constraints-----
- 1 ≤ T ≤ 50
- 1 ≤ n, k ≤ 50
- 1 ≤ ui, vi ≤ n
- ui ≠ vi

-----Example-----
Input
3
3 2
1 2
2 3
3 1
1 2
2 3
4 3
1 2
2 3
2 4

Output:
6
1
39

-----Explanation-----
In the first example, You can color the vertices in the following 6 ways - {1, 1, 1}, {2, 2, 2}, {1, 2, 2}, {1, 1, 2}, {2, 1, 1}, {2, 2, 1}. Note that you can't color the tree in {1, 2, 1} as the vertices in the path connecting vertex 1 and 3, (i.e. 1, 2, 3) don't have same color. You can see that the color of 2nd vertex is not same as that of 1st and 3rd.
In the second example, Only possible coloring you can do is to color all the vertices with color 1.

Difficulty: interview

Starter code:

Solutions:
A = [0] * 100001
M = 1000000007

def nCk(n, k):
 if k ==0 or k ==n:
  return 1
 r = (A[n-k]*A[k])%M
 x = (A[n]*pow(r, M-2, M))%M
 return x

for _ in range(int(input())):
 n, k = list(map(int, input().split()))
 for i in range(n-1):
  u,v = input().split()
 summ = 0
 A[0] = 1
 for i in range(1, len(A)):
  A[i] = (i*A[i-1])%M
 for i in range(min(n, k)):
  b = nCk(k,i+1)
  c = (nCk(n-1,i)*b)%M
  c *= A[i+1]
  summ += (c%M)
  summ %= M
 print(summ)

mod=1000000007
fact=[1]
for i in range(1,200):
 fact.append((fact[-1]*i)%mod)
def ncr(n,r):
 if n<r:
  return 0
 return (((fact[n]*pow(fact[n-r],mod-2,mod))%mod)*pow(fact[r],mod-2,mod))%mod

for _ in range(eval(input())):
 n,k=list(map(int,input().split()))
 for i in range(n-1):
  u,v=list(map(int,input().split()))
 res=0
 for i in range(1,k+1):
  res+=(((ncr(k,i)*ncr(n-1,i-1))%mod)*fact[i])%mod
  res%=mod
 print(res)



MOD = 10**9 + 7

fact = [1 for i in range(101)]
for i in range(2, 100):
 fact[i] = (fact[i - 1] * i) % MOD

inv = [1 for i in range(101)]
for i in range(0, 100):
 inv[i] = pow(fact[i], MOD - 2, MOD)

def C(n, r):
 return (((fact[n] * inv[r]) % MOD) * inv[n - r]) % MOD

t = int(input())
for qq in range(t):
 n, k = list(map(int, input().split()))
 for kk in range(n - 1):
  a, b = list(map(int, input().split()))

 ans = 0
 for i in range(1, k + 1):
  if (i-1) > (n-1):
   break
  cur = C(n - 1, i - 1) * C(k, i)
  cur %= MOD
  cur *= fact[i]
  cur %= MOD
  ans += cur
  ans %= MOD

 print(ans % MOD)