Problem9189--ABC284 —— Ex - Count Unlabeled Graphs

9189: ABC284 —— Ex - Count Unlabeled Graphs

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

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.

Input

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

```
$N$ $K$ $P$
```

Output

Print the answer.

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.

Sample 1 Input

3 1 998244353

Sample 1 Output

4
The following four graphs satisfy the condition.

Sample 2 Input

3 2 998244353

Sample 2 Output

12
The following 12 graphs satisfy the condition.

Sample 3 Input

5 5 998244353

Sample 3 Output

1024

30 15 202300013

62712469

Source/Category