Score : 1200 points
You are given a simple connected undirected graph G consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M.
Edge i connects Vertex a_i and b_i bidirectionally. It is guaranteed that the subgraph consisting of Vertex 1,2,\ldots,N and Edge 1,2,\ldots,N-1 is a spanning tree of G.
An allocation of weights to the edges is called a good allocation when the tree consisting of Vertex 1,2,\ldots,N and Edge 1,2,\ldots,N-1 is a minimum spanning tree of G.
There are M! ways to allocate the edges distinct integer weights between 1 and M. For each good allocation among those, find the total weight of the edges in the minimum spanning tree, and print the sum of those total weights modulo 10^{9}+7.
Input is given from Standard Input in the following format:
N M a_1 b_1 \vdots a_M b_M
Print the answer.
3 3 1 2 2 3 1 3
6
An allocation is good only if Edge 3 has the weight 3. For these good allocations, the total weight of the edges in the minimum spanning tree is 3, and there are two good allocations, so the answer is 6.
4 4 1 2 3 2 3 4 1 3
50
15 28 10 7 5 9 2 13 2 14 6 1 5 12 2 10 3 9 10 15 11 12 12 6 2 12 12 8 4 10 15 3 13 14 1 15 15 12 4 14 1 7 5 11 7 13 9 10 2 7 1 9 5 6 12 14 5 2
657573092
Print the sum of those total weights modulo 10^{9}+7.