Given the sequence , ask the value of
wikipedia: k-permutations of n are the different ordered arrangements of a k-element subset of an n-set (sometimes called variations or arrangements in the older literature). These objects are also known as partial permutations or as sequences without repetition, terms that avoid confusion with the other, more common, meaning of "permutation". The number of such k-permutations of n is denoted variously by such symbols as or ,and its value is given by the product , which is when , and otherwise is equal to .
Assume that
输入
The first line contains an integer — the number of test cases you need to solve.
The first line of each test case contains an integer .
The second line contains space-separated integers — the elements of the array .
输出
For each test case, print the result mod naughty .
样例
标准输入 复制文本 |
1 5 0 1 1 3 2 4 |
标准输出 复制文本 |
245 |
提示
来源
2021 GDCPC 广东省大学生程序设计竞赛