Write a program to count the number of permutations of with exactly cycles, where .
For instance, of the six permutations of , we have:
two with one cycle, which are: and .
three with two cycles, which are: , and .
one with three cycles, which is: .
Input consists of several cases, each with and , such that .
For every case, count the number of permutations of with cycles. As the result can be very large, make the computations modulo .
Let be the number of cases. The expected solution has total cost . You can get up to 80 points with test cases where , with a solution with cost .
Input
3 1 3 2 3 3 4 1 4 2 4 3 4 4 10 2 20 10 100 50
Output
2 3 1 6 11 6 1 1026576 28767655 68128793