Superstition
Today is the long-awaited day for all school students - the first holiday for the new school year. Our main heroine Deni is now in grade 10. She prepared for today - she found that there are n stores downtown and she plans to visit some of them with her friends. But Deni and her friends don’t like some of the connections between the stores and they won't use them. So they have made a list of m pairs of stores such that a pair (x, y) is from the list if they like the connection from store x to y and of course they can reach store x from y and for every pair they have determined the time for travelling the connection (it is the same in both directions). There are no pairs with stores with the same numbers and there are no duplicate pairs.
Deni is very superstitious and one of the superstitions in which she believes is that the total time for travelling must be divisible by d. Deni and her friends don’t have unlimited time so the maximum time they can spend travelling is k. As all girls, Deni is very curious and she starts to count the number of different routes for visiting some of the stores (a store can be visitted more than once). Unfortunately, this number can be large so Deni remembers that she knows you - very good programmer and asks you to write the program superstition, which counts the number of valid routes. One route is valid if it uses the connections from the list of pairs, thetotal time for travelling is divisible by d and it is ≤ k. Two routes are different if there is a difference in the sequences of visited stores. You immediately notice that the answer can be very large and thus Deni tells you that she only wants the remainder when the answer is divided by 1,000,000,007.
Input
From the first line read four integers n (2 ≤ n ≤ 80), m (2 ≤ m ≤ 3160), d and k (2 ≤ d, k ≤ 10^9
). From each of the next m lines read three integers x[i]
, y[i]
and t[i]
- bidirectional connection between x[i]
and y[i]
with time of travel t[i]
(1 ≤ t[i]
≤ 10, 1 ≤ i ≤ m).
Output
Print the number of different valid routes. Since this number may be quite large, you are required to print itsremainder when divided by 1,000,000,007.