Francesco is almost ready to get his Italian driving licence. After successfully passing "Road Rage 2" and "Fundamentals of Speed Camera Avoiding" his only exam left is "Institutions of Public Road Racing".
The exam consists of a race against the clock on the "strade extraurbane secondarie" in the province of Campobasso, a network of bidirectional roads between important villages. The -th road connects villages and and is kilometers long. No two roads connect the same two villages and it's possible to reach any village from any other. Francesco's goal is to reach village (Bojano) starting from village (Termoli).
Thanks to his newly certified speed camera avoidance skills, he knows he can constantly push his inherited 1994 Fiat Punto to its top speed, covering a kilometer in seconds.

Matteo, the examiner from the "Ufficio Motorizzazione Civile Campobasso" secretly wants Francesco to fail, so that he has to pay the "bollo" once again for a new attempt. For this reason, he scheduled the exam in peak agricultural rush hour, knowing well that Molisan farmers will be moving their tractors along the path , with the -th farmer starting their journey at time . It is guaranteed that there exists a road between each pair of consecutive villages in the tractors' path, and that a single tractor won't pass through the same road twice.
These tractors are driven at their maximum legal speed, covering a kilometer in seconds, and the road is not wide enough for Francesco to overtake. Therefore, if he encounters a tractor on his path, he must follow behind it at its speed until the next village. Tractors coming from the opposite direction do not slow him down. Francesco starts his race at time , and if he reaches a village at the same time as a tractor, he can always overtake it before taking the next road.
Help Francesco find out the shortest time in which he can get to Bojano!
Input data
The input file consists of:
- A line containing integers , , , , , .
- A line containing the integers .
- A line containing the integers .
- A line containing the integers .
- A line containing the 64-bit integers (an empty line if ).
- A line containing the integers .
Output data
The output file must contain a single line containing the answer to the problem.
Constraints and clarifications
- .
- .
- .
- .
- .
- and for each .
- for each .
- for each .
- for each .
- Every village is reachable from every village.
- The tractors never use the same road twice.
- No two roads connect the same pair of villages.
| # | Score | Constraints |
|---|---|---|
| 0 | 0 | Examples. |
| 1 | 3 | . |
| 2 | 22 | . |
| 3 | 22 | and for each . and for each . |
| 4 | 53 | No additional restrictions. |
Example
stdin
5 5 2 3 7 67
0 1 1 2 3
1 2 3 3 4
4 5 7 9 3
20 -350
1 3 4
stdout
320
Explanation
The first sample case is shown in the picture below, where the tractors' path is highlighted with a dashed red line.

Francesco can complete his race in seconds as follows:
- First, he follows the path , without encountering tractors, arriving at village at time ;
- Then he takes the last road , getting stuck behind the second tractor, and thus arriving at time .
It can be shown that Francesco cannot take less than seconds to reach Bojano.