atcoder#DIVERTA2019F. Edge Ordering

Edge Ordering

Score : 12001200 points

Problem Statement

You are given a simple connected undirected graph GG consisting of NN vertices and MM edges. The vertices are numbered 11 to NN, and the edges are numbered 11 to MM.

Edge ii connects Vertex aia_i and bib_i bidirectionally. It is guaranteed that the subgraph consisting of Vertex 1,2,,N1,2,\ldots,N and Edge 1,2,,N11,2,\ldots,N-1 is a spanning tree of GG.

An allocation of weights to the edges is called a good allocation when the tree consisting of Vertex 1,2,,N1,2,\ldots,N and Edge 1,2,,N11,2,\ldots,N-1 is a minimum spanning tree of GG.

There are M!M! ways to allocate the edges distinct integer weights between 11 and MM. 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 109+710^{9}+7.

Constraints

  • All values in input are integers.
  • 2N202 \leq N \leq 20
  • N1MN(N1)/2N-1 \leq M \leq N(N-1)/2
  • 1ai,biN1 \leq a_i, b_i \leq N
  • GG does not have self-loops or multiple edges.
  • The subgraph consisting of Vertex 1,2,,N1,2,\ldots,N and Edge 1,2,,N11,2,\ldots,N-1 is a spanning tree of GG.

Input

Input is given from Standard Input in the following format:

NN MM

a1a_1 b1b_1

\vdots

aMa_M bMb_M

Output

Print the answer.

3 3
1 2
2 3
1 3
6

An allocation is good only if Edge 33 has the weight 33. For these good allocations, the total weight of the edges in the minimum spanning tree is 33, and there are two good allocations, so the answer is 66.

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 109+710^{9}+7.