Every year, your uncle organizes a get-together for the whole family. This year, he has decided that the best place for such a gathering is the picturesque city of Delft. However, your family is scattered across various different places in the Benelux, so everyone will have to take the train to Delft.
Train tickets are expensive these days, so your uncle has asked you to find the best deal to get everyone a valid ticket. Your family members have indicated that they do not like detours: they will only want to travel on one of the shortest routes from their starting station to Delft, so you’ll have to take that into account when buying tickets.
After some quick research you find that there are two types of tickets: an individual ticket and a group ticket. Individual tickets are straightforward: the price of an individual ticket between two stations is equal to the shortest distance in kilometers between them. Group tickets are slightly more complicated. When you buy a group ticket, you indicate two stations and the names of any number of people. As long as all the people mentioned on the ticket are present, the group ticket allows them to travel between the two stations. This costs g euros per person, regardless of the distance between the stations. Due to strange regulations, you can only buy one group ticket in total, so you cannot divide the family into two or more groups. Note that a person can use both individual tickets and a group ticket on their journey.
What is the least you have to spend to get all of your family members valid tickets to Delft?
Figure F.1: Visualisation of Sample 2 showing the optimal way of buying tickets for your family members. The thick lines indicate the trajectory of the group ticket and the dashed colored lines show the individual tickets that you need to buy.
输入描述:
The input consists of:
• One line containing four integers: n (2 ≤ n ≤ 1000), the number of train stations, m (n − 1 ≤ m ≤ 105), the number of connections between train stations, p (1 ≤ p ≤ 100), the number of family members, and g (1 ≤ g ≤ 106), the cost per person of a group ticket.
• The next line contains p integers vi (1 ≤ vi ≤ n), the ith of which indicates that family member i starts at station vi.
• Then follow m lines that each contain three integers a, b, and c (1 ≤ a, b ≤ n, a != b, and 1 ≤ c ≤ 106), indicating that there is a bidirectional connection between stations a and b with a length of c kilometers.
There is at most one direct connection between any pair of distinct stations and every station can be reached from any other station.
The station of Delft is always numbered 1.
输出描述:
Output the total cost of the cheapest valid tickets so that every family member can travel from their starting station to Delft.
示例1
输入
复制
6 5 3 10
4 5 6
1 2 10
2 3 10
3 4 10
4 5 2
4 6 3
示例2
输入
复制
7 7 4 10
5 4 4 7
1 2 100
2 3 100
3 4 10
1 5 80
3 5 30
3 6 10
6 7 5
示例3
输入
复制
4 5 2 10
2 4
1 2 20
2 4 5
1 3 20
3 4 5
1 4 30