The last wizard

No attempts yetTime limit1sMemory limit256 MB

Problem

The last wizard in the world, Jaeui, is close to his final moment. Jaeui understands every natural phenomenon and carries vast mana in his body, yet against an incurable disease of unknown cause he could do nothing. Writhing in pain, Jaeui kept preparing an arrangement that stops magic from dying out in the world, and only the finishing touch is left. His closest friend Taehyun receives this arrangement.

Jaeui numbered the 10 kinds of mana he considered essential from 0 to 9 and made them trainable for Taehyun. Taehyun is an ordinary person, so he holds amount 1 of each of the 10 kinds of mana.

One training session has NN ways for mana to increase. Number the ways from 1 to NN. Way ii happens with probability Pi/AP_i / A, and then each of the 10 kinds of mana grows by a fixed amount. The sum of all PiP_i can be smaller than AA, so a session can leave every mana unchanged. The result of one session is independent of the results of the other sessions.

Jaeui takes the product of the amounts of all 10 kinds of mana after training ends as the strength of magic. As the last step of the arrangement, Jaeui wants the expected strength of magic after TT training sessions. He handed the work to you, a friend he is not close to. Help Jaeui.

Input

The first line contains three natural numbers TT, NN, AA separated by spaces. (1T10121 \le T \le 10^{12}, 1N100001 \le N \le 10\,000, 1A1091 \le A \le 10^9)

Each of the next NN lines contains 11 integers separated by spaces. The first integer is PiP_i, and the remaining 10 are the increase of mana 0, the increase of mana 1, ..., the increase of mana 9, in that order. Every PiP_i is at least 0 and the sum of all PiP_i is at most AA. Each increase is an integer between 0 and 9,999, and at least one of the 10 increases on a line is 1 or more.

Output

Multiplying the expected product of the amounts of all 10 kinds of mana after TT training sessions by ATA^T gives an integer. Print that integer modulo 1,000,000,007 on the first line.