#P9374. 「DROI」Round 2 单图
「DROI」Round 2 单图
Background
Rather than writing a weak background, it is better to make a higher-quality problem.
Problem Description
We say that two simple directed graphs are essentially the same if and only if:
- For any pair of vertices , if in graph one can reach starting from , then in graph one can also reach starting from . Conversely, if in graph one can reach starting from , then in graph one can also reach starting from .
If for a simple directed graph , there does not exist any other simple directed graph that is essentially the same as it, then we call graph a single graph.
There are queries. In each query, a positive integer is given. Please output the number of labeled single graphs with vertices.
Input Format
This problem uses multiple test cases.
The first line contains two integers , representing the number of test cases and the modulus.
The next lines each contain one integer, representing for that test case.
Output Format
Output lines. The -th line should contain the answer for the -th test case modulo .
5 998244353
1
3
5
12
888
1
16
986
328006912
535268381
Hint
Constraints
"This problem uses bundled testdata."
-
: , .
-
: .
-
: no special constraints.
For of the testdata: , .
Notes
Some examples are given here to help you understand what a single graph means:
This is a single graph. It can be proven that there is no other graph that is essentially the same as it.

This is not a single graph, because we can add the edge to construct a graph that is essentially the same as it.

This is not a single graph, because we can delete the edge to construct a graph that is essentially the same as it.
Translated by ChatGPT 5
