Ex - Count Unlabeled Graphs Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 600

問題文

あなたは次の一連の操作によってグラフを生成します。

  • 頂点ラベルのない N 頂点の単純無向グラフを 1 つ自由に選ぶ。
  • グラフの各頂点に K 以下の正整数を 1 個ずつ書きこむ。ただし、K 以下の正整数であってどの頂点にも書きこまれない数が存在してはならない。

操作によって得られるグラフとしてあり得るものの個数を \text{mod }P で数え上げてください。(P素数)

ただし、2 つのグラフは、以下の条件を満たすようにそれぞれのグラフの頂点に頂点ラベル v_1, v_2, \dots, v_N をつけられる場合に同じグラフであるとみなします。

  • 1 \leq i \leq N であるすべての i について、頂点 v_i に書きこまれた数が 2 つのグラフの間で一致している。
  • 1 \leq i \lt j \leq N であるすべての (i, j) について、v_iv_j 間の辺の有無が 2 つのグラフの間で一致している。

制約

  • 1 \leq K \leq N \leq 30
  • 10^8 \leq P \leq 10^9
  • P は素数
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N K P

出力

答えを出力せよ。


入力例 1

3 1 998244353

出力例 1

4

条件を満たすグラフは次の 4 通りです。

image


入力例 2

3 2 998244353

出力例 2

12

条件を満たすグラフは次の 12 通りです。

image2


入力例 3

5 5 998244353

出力例 3

1024

入力例 4

30 15 202300013

出力例 4

62712469

Score : 600 points

Problem Statement

You are to generate a graph by the following procedure.

  • Choose a simple undirected graph with N unlabeled vertices.
  • Write a positive integer at most K in each vertex in the graph. Here, there must not be a positive integer at most K that is not written in any vertex.

Find the number of possible graphs that can be obtained, modulo P. (P is a prime.)

Two graphs are considered the same if and only if one can label the vertices in each graph as v_1, v_2, \dots, v_N to satisfy the following conditions.

  • For every i such that 1 \leq i \leq N, the numbers written in vertex v_i in the two graphs are the same.
  • For every i and j such that 1 \leq i \lt j \leq N, there is an edge between v_i and v_j in one of the graphs if and only if there is an edge between v_i and v_j in the other graph.

Constraints

  • 1 \leq K \leq N \leq 30
  • 10^8 \leq P \leq 10^9
  • P is a prime.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

N K P

Output

Print the answer.


Sample Input 1

3 1 998244353

Sample Output 1

4

The following four graphs satisfy the condition.

image


Sample Input 2

3 2 998244353

Sample Output 2

12

The following 12 graphs satisfy the condition.

image2


Sample Input 3

5 5 998244353

Sample Output 3

1024

Sample Input 4

30 15 202300013

Sample Output 4

62712469