Generator

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

You are given nn different integer sequences. All sequences have the same length LL, and all integers in these sequences are from 11 to mm.

You also have a machine that generates a stream of random numbers. Initially, the stream is empty. Every second, the machine generates a random integer from 11 to mm, inclusive, and appends it to the stream. Each random integer is generated independently with the same probability distribution which is given to you.

With probability 11, eventually, each of the nn given sequences appears as LL consecutive elements of the stream. The occurrences of different sequences may overlap. At the first moment when each of the nn given sequences appeared at least once, the machine stops immediately. Your task is to calculate the expected number of seconds after which the machine stops.

입력

There are one or more test cases. The first line of input contains an integer TT, the number of test cases.

Each test case starts with a line containing three positive integers nn, mm and LL: the number of sequences given, the upper bound for the integers which may appear in the sequences and in the stream, and the length of each given sequence, respectively (1n151 \leq n \leq 15, 1m1001 \leq m \leq 100, 1L51041 \leq L \leq 5 \cdot 10^4).

The next line contains mm positive integers a_1,a_2,,a_ma\_1, a\_2, \ldots, a\_m which describe the probability distribution the machine uses to generate the stream. The machine will generate 11 with probability a_1/sa\_1 / s, 22 with probability a_2/sa\_2 / s and so on, where s=a_1+a_2++a_ms = a\_1 + a\_2 + \ldots + a\_m. It is guaranteed that s109s \le 10^9.

Each of the next nn lines contains an integer sequence of length LL. All integers in these sequences are positive and do not exceed mm. It is guaranteed that all nn given sequences are pairwise distinct.

The total sum of nLn \cdot L over all test cases does not exceed 777,777777\\,777.

출력

For each test case, calculate the answer as an irreducible fraction AB\frac{A}{B} and output the integer (AB1)mod(109+7)(A \cdot B^{-1}) \bmod (10^{9} + 7) on a separate line. Here, B1B^{-1} is the multiplicative inverse of BB modulo 109+710^{9} + 7.

It is guaranteed that for all given inputs, the integers BB and 109+710^{9} + 7 are relatively prime.