#P10994. [2015杭电多校]Random Inversion Machine

[2015杭电多校]Random Inversion Machine

Random Inversion Machine

Problem Description

Teacher Mai has a game machine, which has nn slots in a row, numbered from 11 to nn, inclusively. He plays a game with the machine for several rounds. In each round, he divides that row into kk segments with marks at boundaries between adjacent segments. Each segment must contain a positive number of slots. Then, the machine generates a random permutation of {1,2,,n}\{1, 2, \cdots , n\} and displays the permutation on the slots.Finally, the machine calculates the inversion number of each segment and multiplies them together to get the score of the round. The inversion number of a sequence is the number of inversions (also called inversion pairs) in the sequence. Teacher Mai can play the game for as many rounds as he wants, but he must use different partitions in different rounds. Two partitions are considered to be different if there is a mark somewhere in one partition but not in the other. The total game score is simply the sum of the score of each round. However, the machine has been intruded by a malware, which changes the permutation before the machine calculates the score of each round. It sorts the numbers in the mm specific slots with numbers p1,p2,,pmp_1,p_2,\cdots,p_m. For example, if n=4,k=1,m=2,p={1,3}n=4,k=1,m=2,p=\{1,3\} and the permutation generated is (2,4,1,3)(2,4,1,3). The malware will pick numbers 22 and 11 and sort them, changing the permutation into (1,4,2,3)(1,4,2,3). So Teacher Mai will get a score of 22 (pairs (4,2)(4,2) and (4,3)(4,3)) in this round. Teacher Mai wants to know the maximum expected game score he can get.

Input

There are multiple test cases. For each test case, the first line contains three numbers n,k,m(1k,mn100)n,k,m(1\leq k,m\leq n\leq 100). The second line contains mm numbers p1,p2,,pm(1p1<p2<<pmn)p_1,p_2,\cdots,p_m(1\leq p_1<p_2<\cdots<p_m\leq n). In the ii-th test case, n=10in=10i.

Output

As the answer for the problem can be very large, please calculate it as an irreducible fraction A/BA/B and output (AB1)(A*B^{-1}) mod (109+7)(10^9 + 7) for each test case in a separate line. Here, B1B^{-1} is the multiplicative inverse of BB modulo 109+710^9 + 7. The input constraints guarantee that BB and 109+710^9 + 7 are coprime, so this expression is properly defined.

Sample Input

6 2 3
1 4 5
10 3 4
2 6 7 9

Sample Output

225000005
608333402

Author

xudyh

Source

2015 Multi-University Training Contest 9