AtCoder Grand Contest 065
F
Always Perfect
AtCoder
⌀ 3889
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given an even number $N$ and a prime number $M$.

翻译中…

Find the number, modulo $M$, of simple connected undirected graphs $G$ with $N$ vertices numbered $1$ to $N$ that satisfy the following condition:

翻译中…
  • For every spanning tree $T$ of $G$, there is a perfect matching in $T$.
翻译中…

What is a perfect matching in a graph? For a graph $G$, a set of edges $E$ from $G$ is called a perfect matching in $G$ if, for every vertex $v$ in the graph, $E$ contains exactly one edge with $v$ as an endpoint.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 500$
  • $10^8 \leq M \leq 10^9$
  • $N$ is even.
  • $M$ is prime.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N M

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4 998244353
Output #1
15
For example, among the two graphs shown in the figure below, the graph on the left satisfies the condition. On the other hand, the graph on the right does not because there is no perfect matching in the spanning tree with the three edges shown in bold red. ![image](https://img.atcoder.jp/agc065/2ef467c5e79ec3372986afd95c28100a.png)
Input #2
10 998244353
Output #2
128792160
Input #3
300 923223991
Output #3
359143490
题目信息
题号
agc065_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。