Niuniu is (p)reviewing NOIP 2017 problems.
Maybe you have heard NOIP 2017 Day 2 Problem 2 Treasure.
You can find the problem at https://www.nowcoder.com/acm/contest/154/1002. He found that the official data is very weak. Many contestants accepted this problem with search solutions or wrong solutions.
We want to find the sum of weight of all rooted spanning tree.
The weight of a rooted spanning tree is defined as follows.
Enumerate all edges in the tree.
The contribution of an edge is its weight times its depth in the rooted tree.
The depth of a vertex is the number of edges from the root to the vertex.
As the answer might be very large, you only need to output the answer mod 1000000007.


