#P4128. [SHOI2006] 有色图

    ID: 3060 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>搜索2006各省省选上海扩展欧几里德,扩欧群论置换Polya原理

[SHOI2006] 有色图

Description

If every edge of an undirected complete graph (a complete graph means that any two distinct vertices are connected by exactly one edge) is colored with one color, we call such a graph a colored graph. If two colored graphs have the same number of vertices and, after some relabeling of the vertices, the colors of the corresponding edges are identical, then the two colored graphs are said to be isomorphic. The following two graphs are isomorphic, because if you permute the vertices of the first graph (1,2,3,4)(1,2,3,4) into (4,1,2,3)(4,1,2,3) in the second graph, you will find they are the same.

Your task is to compute, among all undirected complete graphs on nn vertices whose edges are colored using at most mm colors, how many pairwise non-isomorphic graphs there are. Since the answer can be very large, you only need to output the remainder modulo pp (where pp is a prime).

Input Format

The input contains a single line with three positive integers n,m,pn,m,p.

Output Format

Output the remainder of the total count modulo pp.

1 1 2
1
3 2 97
4
3 4 97
20

Hint

For 100%100\% of the testdata, 1n531 \leq n \leq 53, 1m10001 \leq m \leq 1000, n<p109n < p \leq 10^9.

Translated by ChatGPT 5