Under construction

Still being built. Things may change

GPS Hack

Time limit1sMemory limit1024 MB

Summary
Count the s-to-t routes with total time exactly L, where the hacked GPS may deviate from a shortest path at most once, modulo 1e9+7.
Level

Hard8 of 10

Topics
Shortest path, Dynamic programming, Graph
Solved
No attempts yet

Problem

Denis is a student and he failed his data security exam, so today he is retaking it. He woke up late and decided to take a taxi.

Denis lives in a city that can be represented as nn crossroads connected by mm bidirectional roads. The time needed to drive along each road is known. Denis lives near crossroad ss, and the university is near crossroad tt. As soon as the taxi reaches the university, Denis leaves it and rushes to his exam.

Unfortunately, the situation is more complicated. Hackers have hacked the GPS in Denis's taxi. When the GPS works properly, it leads you to the destination as fast as possible. At every crossroad it shows which road to take to finish the journey in the fastest way. If more than one road is possible, the GPS can show any of them. Hackers can make the GPS show any road they want, but at most once.

Denis does not remember exactly how he got to the university, but he remembers that the ride took LL time. The teacher knew about the GPS attack, so he asked Denis to count the number of different possible routes from his home to the university as part of his retake.

Help Denis count the routes from crossroad ss to crossroad tt that take LL time and are possible given the GPS hack. Since the number can be very large, print it modulo 109+710^9 + 7.

Input

The first line contains two integers nn and mm, the number of crossroads and roads in the city (2≤n≤2⋅1052 \leq n \leq 2 \cdot 10^5, 1≤m≤min⁡(2⋅105,n(n−1)2)1 \leq m \leq \min(2 \cdot 10^5, \frac{n(n-1)}{2})).

The second line contains three integers ss, tt, and LL, the crossroad where Denis lives, the crossroad near the university, and the ride time (1≤s,t≤n1 \leq s, t \leq n, s≠ts \neq t, 1≤L≤2⋅10141 \leq L \leq 2 \cdot 10^{14}).

The next mm lines each contain three integers vv, uu, ww (1≤v,u≤n1 \leq v, u \leq n, v≠uv \neq u, 1≤w≤1091 \leq w \leq 10^9), the two crossroads connected by the road and the time needed to drive along it.

All roads are bidirectional, and each pair of crossroads is connected by at most one road. No road connects a crossroad to itself. It is guaranteed that a route from ss to tt exists.

Output

Print the number of routes Denis could have taken from ss to tt with total time LL, modulo 109+710^9 + 7.

Examples1

  1. Example 1

    Input
    6 7
    1 6 12
    1 2 2
    1 3 4
    2 5 2
    3 5 4
    2 4 4
    4 6 6
    5 6 4
    
    Expected output
    4