#P9897. Cargo
Cargo
Cargo
Problem Description
There're stores selling kinds of items. Each store only sells one kind of item, the -th store sells the -th kind of item. You're going to buy some items. You do the following operation times: choose a store at random, and buy one item from that store. Let there are stores selling item . After all the operations, you will get unsatisfied, if and only if the following condition is satisfied:
- There exists an item , where you hold exact of them, and they are all from different stores. For example, if store and are selling item , and after operations, you hold exactly two items , and one of them is from store , where the other one is from store , you will get unsatisfied. You want to know the possibility of not getting unsatisfied after operations. Output it modulo .
Input
The first line contains the number of test cases (). For each test case: The first line contains three integers: (,). The following line contains integers (). It is guaranteed that each of the kinds of items will appear at least once. There will be no more than test cases where .
Output
One single integer, represents the answer.
Sample Input
4
3 2 3
1 1 2
1 1 1
1
6 3 4
1 1 1 2 3 3
8 4 19908
1 1 2 2 3 3 3 4
Sample Output
221832079
0
465231165
665765722
Source
2023“钉耙编程”中国大学生算法设计超级联赛(9)