PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000427. Nỗi sợ nhện (Arachnophobia)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nỗi sợ nhện (Arachnophobia)

Arachnophobia

Source: Kattis – https://open.kattis.com/problems/arachnophobia

Version: Phuoc Hung OJ Extended

Problem Statement

Anthony wants to reach a concert in ByteLand. There are NN intersections and MM bidirectional roads with positive integer lengths. He starts at ss, must reach tt within TT seconds, and travels at one meter per second.

Some intersections contain spiders. Define the distance between intersections as the shortest-path distance in the original road network. For a route, its safety value DD is the minimum distance from any intersection on that route (including both endpoints) to any spider intersection.

Find the maximum safety value among routes with total length at most TT.

Input

The first line contains N,M,TN,M,T. The next MM lines contain u,v,du,v,d, describing a road of length dd between uu and vv. The next line contains s,ts,t. The final line contains KK followed by the KK spider intersections a1,…,aKa_1,\ldots,a_K.

Output

Print the maximum possible integer DD.

Subtasks

Common conditions apply to all subtasks. Scoring groups are added by Phuoc Hung OJ.

1≤T≤1091\le T\le10^9; 0≤u,v,s,t,ai<N0\le u,v,s,t,a_i<N; u≠vu\ne v, s≠ts\ne t; 1≤d≤10 0001\le d\le10\,000; 1≤K≤N1\le K\le N.

The graph is connected and simple. A route from ss to tt of length at most TT always exists. All input values are integers.

Subtask 1 (20 points)

  • 2≤N≤102\le N\le10, N−1≤M≤min⁡(200 000,N(N−1)/2)N-1\le M\le\min(200\,000,N(N-1)/2).

Subtask 2 (30 points)

  • 2≤N≤2002\le N\le200, N−1≤M≤min⁡(200 000,N(N−1)/2)N-1\le M\le\min(200\,000,N(N-1)/2).

Subtask 3 (50 points)

  • 2≤N≤100 0002\le N\le100\,000, 1≤M≤min⁡(200 000,N(N−1)/2)1\le M\le\min(200\,000,N(N-1)/2).

Examples

Example 1

Input

4 4 3000
0 1 1
1 3 1
2 0 2018
2 3 42
0 3
1 1

Output

1

Explanation

Route 0→2→30\to2\to3 has length 20602060 and safety 11. The start is only one meter from a spider, so no route can do better.

Example 2

Input

4 4 10
0 1 1
1 3 1
2 0 2018
2 3 42
0 3
1 1

Output

0

Explanation

The longer route exceeds the time limit. The feasible route 0→1→30\to1\to3 passes through a spider intersection, giving 00.