#P7729. 交通运输(Wormhole Transportation)

交通运输(Wormhole Transportation)

Description

There are nn bases on Eternal Continent, numbered 1,2,,n1, 2, \ldots, n.

Now there are mm transportation tasks. The ii-th task is: transport goods from base uiu_i to base viv_i.

However, transportation after the disaster is not well developed, so you decide to use wormholes. You can build a wormhole between any two different bases x,yx, y. Transporting goods from one end of the wormhole to the other end only takes 11 unit of time.

Also, transportation is bidirectional. That is, if you build a wormhole connecting bases aa and bb, then goods can be transported from base aa to base bb, and also from base bb to base aa.

But building wormholes is expensive. You decide to build exactly m1\boldsymbol{m - 1} wormholes, and no two wormholes may connect the exact same pair of bases.

You want to know, among all construction plans, what is the minimum possible total time spent for the mm transportation tasks. In addition, under the condition that this total time is minimized, how many different wormhole construction plans are there.

Since the answer to the second question may be very large, you only need to output it modulo 109+7{10}^9 + 7.

Input Format

The first line contains three integers n,m,tn, m, t, where tt is the subtask ID. For the samples, t=0t=0.

The next mm lines each contain two integers ui,viu_i, v_i.

Output Format

The first line contains one integer, the minimum total time spent for the mm transportation tasks.

The second line contains one integer, the number of wormhole construction plans modulo 109+7{10}^9 + 7.

3 3 0
1 2
2 3
3 1

4
3

5 6 0
1 2
2 3
1 4
4 3
1 5
5 3

8
30

Hint

[Sample 1 Explanation]

There are three construction plans.

One plan is to build wormholes between cities 1,21, 2 and between cities 2,32, 3. Then the time for the first two tasks is 11, and the time for the last task is 22.

The other two plans are: build wormholes between cities 1,21, 2 and 1,31, 3, or build wormholes between cities 1,31, 3 and 2,32, 3.


[Constraints]

For all data, 2n20002 \le n \le 2000, 2nm2×1072 \le n \cdot m \le 2 \times {10}^7, 1ui,vin1 \le u_i, v_i \le n, and uiviu_i \ne v_i.

It is guaranteed that all unordered pairs (ui,vi)(u_i, v_i) are pairwise distinct, and that there exists at least one valid wormhole construction plan.

Subtask ID Score nn \le Special Constraints Partial Score
11 1010 66 None 00
22 1212 20002000 m=nm=n, and ui=i, vi=imodn+1u_i=i,\ v_i=i\bmod n+1 33
33 The graph formed by treating all (ui,vi)(u_i,v_i) as undirected edges is a cactus forest
44 2525 The graph formed by treating all (ui,vi)(u_i,v_i) as undirected edges is an almond 88
55 2727 300300 m1000m\leq 1000
66 1414 20002000 None 33

Cactus forest: an undirected graph in which each edge belongs to at most one simple cycle.

Almond: a connected undirected graph in which there are exactly two vertices with degree greater than 22, all other vertices have degree exactly 22, and all cycles pass through the two vertices with degree greater than 22.

If for all test points of a subtask, your answer to the first question is all correct, but your answer to the second question is not all correct, you will receive the partial score for this subtask.

Translated by ChatGPT 5