#Q133. 「一本通 4.4 例 2」暗的连锁
「一本通 4.4 例 2」暗的连锁
Description
Original problem from: POJ 3417
Dark is an undirected graph with nodes and two types of edges: primary edges and additional edges. Dark has primary edges, and there exists a path composed solely of primary edges between any two nodes in Dark. Additionally, Dark has additional edges.
Your task is to split Dark into two disconnected parts. Initially, all additional edges of Dark are invincible, and you can only choose to cut one primary edge. Once you cut a primary edge, Dark enters defense mode: the primary edges become invincible, and the additional edges can now be cut. However, your ability allows you to cut only one additional edge in this mode.
Now, you want to know how many different schemes there are to defeat Dark. Note that even if cutting the primary edge alone already splits Dark into two parts, you still need to cut one additional edge to be considered as having defeated Dark.
Input Format
The first line contains two integers and ;
The following lines each contain two integers and , indicating a primary edge between and ;
The subsequent lines provide the additional edges in the same format.
Output Format
Output an integer representing the answer.
Sample 1
4 1
1 2
2 3
1 4
3 4
3
Data Range and Hints
For of the data, ;
For of the data, . It is guaranteed that the answer does not exceed .