#P17461. [GESP202609 八级] 生成树计数
[GESP202609 八级] 生成树计数
Problem Description
Given an undirected connected graph with vertices and edges, the vertices are numbered in order. has the following special properties:
- Each edge in belongs to at most one simple cycle.
- has no multiple edges or self-loops.
A simple cycle means a cycle in which all vertices are distinct, and no edge is repeated.
Please find the number of different spanning trees of . Two spanning trees are different if and only if there exists an edge that appears in one spanning tree but not in the other.
Since the answer may be very large, you only need to output the result modulo .
Input Format
The first line contains two positive integers , representing the number of vertices and the number of edges of , respectively.
In the next lines, each line contains two integers , representing an undirected edge connecting vertices .
Output Format
Output one line with one integer, representing the number of different spanning trees of modulo .
7 8
1 2
2 3
3 1
3 4
4 5
5 6
6 7
7 4
12
5 4
1 2
1 3
2 4
2 5
1
Hint
For of the testdata, it is guaranteed that and .
For of the testdata, it is guaranteed that and .
For all testdata, it is guaranteed that , , and .
Translated by ChatGPT 5