Chiaki has a tree with n vertices. There might be a token colored white or black on each vertex of the tree, and there are exactly w white tokens and exactly b black tokens. Also, for each pair of vertices with the same color of tokens, there must have been a path between them such that every vertex on the path contains a token of the same color. Chiaki would like to perform the following operations: Choose a vertex u with a token. Choose a path p1,p2,…,pk such that p1=up_1=up1=u, all vertices p1,p2,…,pk1 contain a token of the same color, and there's no token in pkp_kpk. Move the token in p1p_1p1 to pkp_kpk. Now there's no token in p1p_1p1 and pkp_kpk contains a token. For two initial configurations of tokens S and T, if Chiaki could perform the above operations several times to make S become T, S and T are considered equivalent. Let f be the number of equivalence classes , Chiaki would like to know the value of mod.leftbmod .mod.
Chiaki has a tree with n vertices. There might be a token colored white or black on each vertex of the tree, and there are exactly w white tokens and exactly b black tokens. Also, for each pair of vertices with the same color of tokens, there must have been a path between them such that every vertex on the path contains a token of the same color. Chiaki would like to perform the following operations: Choose a vertex u with a token. Choose a path p1,p2,…,pkp_1,p_2,dots,p_kp1,p2,…,pk such that p1=up_1=up1=u, all vertices p1,p2,…,pk−1p_1,p_2,dots,p_{k-1}p1,p2,…,pk−1 contain a token of the same color, and there's no token in pkp_kpk. Move the token in p1p_1p1 to pkp_kpk. Now there's no token in p1p_1p1 and pkp_kpk contains a token. For two initial configurations of tokens S and T, if Chiaki could perform the above operations several times to make S become T, S and T are considered equivalent. Let f(w, b) be the number of equivalence classes (an equivalence class is a maximal set of configurations where each two of them are equivalent; all equivalence classes partition the set of all configurations), Chiaki would like to know the value of (∑w=1n−1∑b=1n−ww⋅b⋅f(w,b)) mod (109+7).left(sum_{w=1}^{n-1}sum_{b=1}^{n-w} w cdot b cdot f(w, b) right)bmod (10^9+7).(∑w=1n−1∑b=1n−ww⋅b⋅f(w,b))mod(109+7).