Country Traffic

Time limit: 0.5sMemory limit: 256MBInput: Output:

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 MM bidirectional roads between NN important villages. The ii-th road connects villages XiX_i and YiY_i and is ZiZ_i 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 N−1N-1 (Bojano) starting from village 00 (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 UU seconds.

Francesco’s trusty Punto.\text{Francesco's trusty Punto.}

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 KK Molisan farmers will be moving their tractors along the path P0→P1→⋯→PL−1P_0 \rightarrow P_1 \rightarrow \dots \rightarrow P_{L-1}, with the ii-th farmer starting their journey at time TiT_i. 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 VV 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 00, 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 NN, MM, KK, LL, UU, VV.
  • A line containing the MM integers X0,…,XM−1X_0, \ldots, X_{M-1}.
  • A line containing the MM integers Y0,…,YM−1Y_0, \ldots, Y_{M-1}.
  • A line containing the MM integers Z0,…,ZM−1Z_0, \ldots, Z_{M-1}.
  • A line containing the KK 64-bit integers T0,…,TK−1T_0, \ldots, T_{K-1} (an empty line if K=0K=0).
  • A line containing the LL integers P0,…,PL−1P_0, \ldots, P_{L-1}.

Output data

The output file must contain a single line containing the answer to the problem.

Constraints and clarifications

  • 2≤N≤100 0002 \le N \le 100\ 000.
  • 1≤M≤200 0001 \le M \le 200\ 000.
  • 1≤U≤V≤1 000 0001 \le U \le V \le 1\ 000\ 000.
  • 0≤K≤100 0000 \le K \le 100\ 000.
  • 2≤L≤200 0002 \le L \le 200\ 000.
  • Xi≠YiX_i \ne Y_i and 0≤Xi,Yi<N0 \le X_i,Y_i < N for each 0≤i<M0 \le i < M.
  • 1≤Zi≤1 000 0001 \le Z_i \le 1\ 000\ 000 for each 0≤i<M0 \le i < M.
  • −1018≤Ti≤1018-10^{18} \le T_i \le 10^{18} for each 0≤i<K0 \le i < K.
  • 0≤Pi<N0 \le P_i < N for each 0≤i<L0 \le i < L.
  • 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 K=0K=0.
2 22 K≤1K \le 1.
3 22 M=N−1M=N-1 and i=Xi=Yi−1i=X_i=Y_i-1 for each 0≤i<N−10 \le i < N-1. L=NL=N and Pi=iP_i=i for each 0≤i<N0 \le i < N.
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 320320 seconds as follows:

  • First, he follows the path 0→1→2→30 \rightarrow 1 \rightarrow 2 \rightarrow 3, without encountering tractors, arriving at village 33 at time (4+5+9)⋅7=126(4+5+9) \cdot 7 = 126;
  • Then he takes the last road 3→43 \rightarrow 4, getting stuck behind the second tractor, and thus arriving at time −350+(7+3)⋅67=320-350+(7+3)\cdot 67=320.

It can be shown that Francesco cannot take less than 320320 seconds to reach Bojano.

Log In or Sign Up to be able to send submissions!