#D11152. Timing
Timing
Timing
Problem
Given an undirected graph of vertices edges. Each vertex has a different number from to . You want to start at vertex at time and move to vertex . Parameters are set on each side, and if the time starts from the vertex on one side of that side, the time $ t + ceil \ left (\ cfrac {b) is on the other vertex. } {t + a} \ right) It is known to reach $. Here, represents the smallest integer greater than or equal to . Also, each vertex can consume any extra non-negative integer time. That is, when you are at the peak at time , you can choose any non-negative integer and wait until time . Aiming for the fastest and strongest algorithm, you want to find the minimum amount of time it takes to move from vertex to vertex .
Constraints
The input satisfies the following conditions.
- ,
- ,
- All given inputs are integers
Input
The input is given in the following format.
::
In the line, the number of vertices , the number of edges , the start vertex number , and the goal vertex number are given, separated by blanks. In the following line, the information of each side is given separated by blanks. The information on the line indicates that there is an edge such that between the vertex and the vertex .
Output
Output the minimum time it takes to move from vertex to vertex . If you can't move from vertex to vertex , print instead.
Examples
Input
2 1 1 2 1 2 1 100
Output
19
Input
2 1 1 2 1 2 50 100
Output
2
Input
3 1 1 3 1 2 1 1
Output
-1
Input
3 3 1 3 1 2 1 1 2 3 1 6 2 3 50 100
Output
3
Input
3 3 1 3 1 2 10 100 2 3 1 6 2 3 50 100
Output
11
inputFormat
input satisfies the following conditions.
- ,
- ,
- All given inputs are integers
Input
The input is given in the following format.
::
In the line, the number of vertices , the number of edges , the start vertex number , and the goal vertex number are given, separated by blanks. In the following line, the information of each side is given separated by blanks. The information on the line indicates that there is an edge such that between the vertex and the vertex .
outputFormat
Output
Output the minimum time it takes to move from vertex to vertex . If you can't move from vertex to vertex , print instead.
Examples
Input
2 1 1 2 1 2 1 100
Output
19
Input
2 1 1 2 1 2 50 100
Output
2
Input
3 1 1 3 1 2 1 1
Output
-1
Input
3 3 1 3 1 2 1 1 2 3 1 6 2 3 50 100
Output
3
Input
3 3 1 3 1 2 10 100 2 3 1 6 2 3 50 100
Output
11
样例
2 1 1 2
1 2 1 100
19