NC54482. Cactus Automorphisms
描述
输入描述
The first line of the input file contains two integer numbers n and m (1 ≤ n ≤ 50 000, 0 ≤ m ≤ 50 000). Here n is the number of vertices in the graph. Vertices are numbered from 1 to n. Edges of the graph are represented by a set of edge-distinct paths, where m is the number of such paths.
Each of the following m lines contains a path in the graph. A path starts with an integer number ki (2 ≤ ki ≤ 1000) followed by ki integers from 1 to n. These ki integers represent vertices of a path. Adjacent vertices in a path are distinct. Path can go to the same vertex multiple times, but every edge is traversed exactly once in the whole input file. There are no multiedges in the graph (there is at most one edge between any two vertices).
The graph in the input file is a cactus.
输出描述
On the first line of the output file write number k — the number of prime factors in the factorization of the number of graph automorphisms. Write 0 if the number of graph automorphisms is 1. On the following k lines write prime numbers pi and their powers qi separated by a space. Prime numbers must be given in ascending order.
示例1
输入:
15 3 9 1 2 3 4 5 6 7 8 3 7 2 9 10 11 12 13 10 5 2 14 9 15 10
输出:
1 2 2
说明:
The first sample input corresponds to the picture from the problem statement. This graphs has 4 = 22 automorphisms.示例2
输入:
2 1 2 1 2
输出:
1 2 1
说明:
The second sample input is a simple graph with two vertices and one edge between them that has 2 = 21 automorphisms.示例3
输入:
15 7 3 1 2 3 3 4 2 5 3 6 2 7 3 8 2 9 3 10 2 11 3 12 2 13 3 14 2 15
输出:
6 2 11 3 5 5 2 7 2 11 1 13 1
说明:
The third sample input is a “star” graph with a center vertex and 14 rays that has 14! = 87 178 291 200 = 211 × 35 × 52 × 72 × 111 × 131 automorphisms.