The last wizard
Time limit1sMemory limit256 MB
Ten counters start at 1 and grow through T random additive updates; output their expected product scaled by A to the T modulo 1000000007.
- Level
Hard8 of 10
- Topics
- Probability, Combinatorics, Matrix, Dynamic programming
- Solved
- No attempts yet
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 ways for mana to increase. Number the ways from 1 to . Way happens with probability , and then each of the 10 kinds of mana grows by a fixed amount. The sum of all can be smaller than , 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 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 , , separated by spaces. (, , )
Each of the next lines contains 11 integers separated by spaces. The first integer is , and the remaining 10 are the increase of mana 0, the increase of mana 1, ..., the increase of mana 9, in that order. Every is at least 0 and the sum of all is at most . 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 training sessions by gives an integer. Print that integer modulo 1,000,000,007 on the first line.