#P2183. [国家集训队] 礼物
[国家集训队] 礼物
Description
Xiao E bought gifts from a store and plans to give them to people, where the number of gifts given to the -th person is . Please help compute the number of ways to give out the gifts (two ways are considered different if and only if there exists a person who receives different gifts in the two ways). Since the number of ways can be very large, you only need to output the result modulo .
Input Format
The first line contains an integer , the modulus.
The second line contains two integers and , representing the number of gifts Xiao E bought and the number of recipients, respectively.
Lines to : each line contains an integer; the integer on the -th line denotes the number of gifts given to the -th person.
Output Format
If there is no feasible way, output Impossible; otherwise, output a single integer representing the number of ways modulo .
100
4 2
1
2
12
100
2 2
1
2
Impossible
Hint
Explanation for Sample 1
Separated by /, where the parts before and after / represent the gift IDs for the first and second persons, respectively. The possible ways are as follows:
1/23 1/24 1/34
2/13 2/14 2/34
3/12 3/14 3/24
4/12 4/13 4/23
Constraints
Let , where is a prime.
For of the testdata, , , .
In the remaining of the testdata, about satisfy , , , and about satisfy .
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号