#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 G,HG, H are essentially the same if and only if:

  • For any pair of vertices (u,v)(u, v), if in graph GG one can reach vv starting from uu, then in graph HH one can also reach vv starting from uu. Conversely, if in graph HH one can reach vv starting from uu, then in graph GG one can also reach vv starting from uu.

If for a simple directed graph GG, there does not exist any other simple directed graph HH that is essentially the same as it, then we call graph GG a single graph.

There are TT queries. In each query, a positive integer nn is given. Please output the number of labeled single graphs with nn vertices.

Input Format

This problem uses multiple test cases.

The first line contains two integers T,modT, mod, representing the number of test cases and the modulus.

The next TT lines each contain one integer, representing nn for that test case.

Output Format

Output TT lines. The ii-th line should contain the answer for the ii-th test case modulo modmod.

5 998244353
1
3
5
12
888
1
16
986
328006912
535268381

Hint

Constraints

"This problem uses bundled testdata."

  • Subtask1(30%)\operatorname{Subtask} 1(30\%): T=1T = 1, n5n \leq 5.

  • Subtask2(50%)\operatorname{Subtask} 2(50\%): T10T \leq 10.

  • Subtask3(20%)\operatorname{Subtask} 3(20\%): no special constraints.

For 100%100\% of the testdata: 1T,n10001 \leq T, n \leq 1000, 1mod1091 \leq mod \leq 10^9.

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 (5,2)(5, 2) to construct a graph that is essentially the same as it.


This is not a single graph, because we can delete the edge (1,3)(1, 3) to construct a graph that is essentially the same as it.

Translated by ChatGPT 5