문제
Consider a permutation of integers from 1 to . We call a sub-segment of the permutation an interval if it is a reordering of some set of consecutive integers. For example, the permutation has the intervals , , , and others.
Each permutation has some trivial intervals — the full permutation itself and every single element. We call a permutation interval-free if it does not have non-trivial intervals. In other words, interval-free permutation does not have intervals of length between 2 and inclusive.
Your task is to count the number of interval-free permutations of length modulo prime number .
입력
In the first line of the input there are two integers () and () — the number of test cases to solve and the prime modulo. In each of the next lines there is one integer () — the length of the permutation.
출력
For each of test cases print a single integer — the number of interval-free permutations modulo .
예제 입력 1
4 998244353
1
4
5
9
예제 출력 1
1
2
6
28146
예제 입력 2
1 437122297
20
예제 출력 2
67777575
노트
For the only permutation is interval-free. For two interval-free permutations are and . For — , , , , , and . We will not list all 28146 for , but for example , , , and are interval-free.
The exact value for is 264111424634864638.
코드를 제출하려면 로그인이 필요합니다.
로그인