题号:NC210245
时间限制:C/C++/Rust/Pascal 6秒,其他语言12秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
We define the value of an unrooted tree T as
%7D%20(d(u))%5E2)
, where V(T) is the set of all vertices of T, and d(u) is the degree of the vertex u. We define the value of a forest as the sum of the value of all trees from it. Now we want you to answer the sum of the value of all forests with N labeled vertices.
In order to avoid calculations of huge integers, report answer modulo a prime M instead.
输入描述:
There are multiple test cases. The first line of the input contains two integers T and M (
, and M is a prime),
indicating the number of test cases and the modulus.
For each test case, the only line contains an only integer N (
).
输出描述:
For each test case, output the answer modulo M in one line.