
120  ZOJ Monthly, September 2012  A
Kitty is a little cat. She is crazy about a game recently. There are n scenes in the game(mark from 1 to n). Each scene has a number p_{i}. Kitty's score will become least_common_multiple(x,p_{i}) when Kitty enter the i^{th} scene. x is the score that Kitty had previous. Notice that Kitty will become mad If she go to another scene but the score didn't change. Kitty is staying in the first scene now(with p_{1} score). Please find out how many paths which can arrive at the n^{th} scene and has k scores at there. Of course, you can't make Kitty mad. We regard two paths different if and only if the edge sequence is different. InputThere are multiple test cases. For each test case: The first line contains three integer n(2 ≤ n ≤ 2000), m(2 ≤ m ≤ 20000), k(2 ≤ k ≤ 10^{6}). Then followed by m lines. Each line contains two integer u, v(1 ≤ u, v ≤ n, u ≠ v) indicate we can go to v^{th} scene from u^{th} scene directly. The last line of each case contains n integer p_{i}(1 ≤ p_{i} ≤ 10^{6}). Process to the end of input. OutputOne line for each case. The number of paths module 1000000007. Sample Input5 6 84 1 2 2 5 1 3 3 5 1 4 4 5 1 5 4 12 21 Sample Output2 Author: CHEN, Weijie 