#Q94. 「一本通 3.5 例 2」最大半连通子图
「一本通 3.5 例 2」最大半连通子图
Description
Original source: ZJOI 2007
A directed graph is called Semi-Connected if for every pair of vertices , there exists either a directed path from to or a directed path from to . In other words, for any two vertices and in the graph, there is at least one directed path connecting them in some direction.
If satisfies that consists of all edges in that are incident to vertices in , then is called an induced subgraph of . If is an induced subgraph of and is semi-connected, then is referred to as a semi-connected subgraph of . If is a semi-connected subgraph of with the maximum number of vertices, then is called a maximum semi-connected subgraph of .
Given a directed graph , determine the number of vertices in its maximum semi-connected subgraph and the number of distinct maximum semi-connected subgraphs . Since might be very large, only output the remainder of divided by .
Input Format
The first line contains three integers . Here, and represent the number of vertices and edges in graph , respectively, and is the modulus as described above.
The next lines each contain two integers and , indicating a directed edge .
Each vertex in the graph is labeled from to . It is guaranteed that no duplicate edges will appear in the input.
Output Format
The output should consist of two lines. The first line contains the integer , and the second line contains .
Sample 1
6 6 20070603
1 2
2 1
1 3
2 4
5 6
6 4
3
3
Constraints & Hints
For of the data, ; For of the data, ; For of the data, , , and .