logo AlgoBeat OnlineJudge
登录 注册

#213743. [NWRRC 2021] First to Solve

内存限制:512 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The famous Forcedeltas Programming Contest features contestants, problems, and lasts for minutes.

For each contestant and each problem , an integer is known. If , it means that contestant can not solve problem . Otherwise, it means that contestant can solve problem in exactly minutes.

All contestants will follow the same strategy. Specifically, each contestant will form a list of all problems they can solve, shuffle the list uniformly at random, and solve the problems in that order, until the list ends or the contest is over.

For example, if the list for contestant looks like after shuffling, then they will solve problem at minute , problem at minute , and so on. Note that no problem can be solved at minute or later.

We'll say that contestant gets the award for problem if no other contestant solves problem strictly earlier. In particular, it means that multiple contestants can get the award for the same problem.

Find the expected number of awards each contestant will get, modulo (see the Output section for details).

输入格式

The first line contains three integers , , and --- the number of contestants, the number of problems, and the length of the contest in minutes (; ; ).

The -th of the following lines contains integers (). The -th of these integers denotes the number of minutes required for contestant to solve problem , or if contestant can not solve problem .

输出格式

Print integers --- the expected number of awards contestants will get, modulo .

Formally, let . It can be shown that the expected number of awards can be expressed as an irreducible fraction , where and are integers and . Print the integer equal to . In other words, print such an integer that and .

样例

样例输入 1

5 3 60
30 0 0
40 20 0
30 60 0
0 0 0
60 60 1

样例输出 1

1
1
249561089
0
499122177

数据范围与提示

In the example test, contestant will always get the award for problem , contestant will always get the award for problem , the expected number of awards contestant will get is , contestant will never get any awards, and the expected number of awards contestant will get is .