#P5434. 有标号荒漠计数
有标号荒漠计数
Background
As everyone knows, counting cacti is a very easy counting problem, so we are going to make it harder.jpg.
Problem Description
A cactus is an undirected connected graph. In a cactus, any edge appears in at most one cycle. Also, in the cactus defined in this problem, the cactus must have no multiple edges and no self-loops.
A desert is an undirected graph in which every maximal connected component is a cactus.
Given an integer , find how many different deserts with vertices there are (the vertices are labeled).
Since the answer may be very large, you only need to output it modulo .
Input Format
One line with one integer .
Output Format
One line with one integer, the answer modulo .
3
8
Hint
For the sample, all possible cases are as follows:

You can see that there are no more deserts.
Constraints:
For of the testdata: .
For of the testdata: .
Translated by ChatGPT 5