2022 软件学院 ACM 集训队筛选赛

Problem H. Happy Ending

It's a beautiful day outside. Birds are singing, flowers are blooming... On days like these, kids like you...should take a fantastic trip to the Blue Planet.

Here, Baicha would share nice white tea with you, Sangze would take your girl suit photos with Jinle and Guodong would PS it elaborately. Miming would teach you useful gameplay tips, and then Xingyue would become your teammate and explore the magic-made games like ONU and the Land of the Kernel with you. If tired, Hefeng would tell you the tales happened in these hundreds of years and Yunyan would heal you with the Abyss power. While Tianjiang would watching you on the sly.

Enjoy yourself in the Blue Planet!

There're nn activities indexed from 11 to nn (inclusive) on the Blue Planet. And there're mm restrictions, each restriction (u,v)(u,v) denotes that activity vv can be be held only after uu has been held. If any of the restrictions (u,v)(u,v) is satisfied, then vv can be held. Holding the activity ii needs aia_i hours. You can hold only one activity each time. You only hope to finish holding the activity nn within no more than tt hours in total. Suppose there're rr schemes can satisfy your hope, you should calculate rmod(109+7)r\bmod(10^9+7) .

输入

Input the first line with three integers n,m,t(2n104,1m3×104,1t103)n,m,t(2\le n\le10^4,1\le m\le3\times 10^4,1\le t\le10^3) .

Input the second lines with nn integers, the i-th integer denotes ai(1ai103)a_i(1\le a_i\le10^3) .

Then input mm lines, each line contains two integers u,v(1u,vn,uv)u,v(1\le u, v\le n,u\neq v) .

It's guaranteed that every activity can be held, i.e. there's no restriction cycles in the given data.

输出

Output one line with one integer rmod(109+7)r\bmod(10^9+7) .

样例

标准输入 复制文本
4 5 10
2 2 3 5
1 2
1 3
2 3
2 4
3 4
标准输出 复制文本
2
标准输入 复制文本
4 5 8
2 2 3 5
1 2
1 3
2 3
2 4
3 4
标准输出 复制文本
0
标准输入 复制文本
4 4 8
2 2 8 5
2 4
2 1
1 4
3 4
标准输出 复制文本
1

提示

In the first example, two schemes are holding (1,2,4),(1,3,4)(1,2,4),(1,3,4) in order.

In the second example, none of schemes are available.

In the third example, the only scheme is holding (2,4)(2,4) in order.

2023/4/4 Update statement.

登录以提交代码。
单点时限 2 秒
内存限制 256 MB
提交 50
通过 5

A B C D E F G H

鉴于过题情况不理想,比赛时间延长1小时,22:00开始封榜。
可以尝试一下做D,G或H题。
C题是签到题。
请注意题目难度与题目顺序无关。