Pedal Power

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You're ready to start your semester off right! Well, almost... you have everything listed on your calendar, you just bought a brand new bike, but you haven't yet planned your commute! You are quite busy this semester, and so you decide to plan a route for all your classes and appointments which requires the least amount of travel time.  You know how long certain routes will take with and without a bike.  You can choose to ride or not ride your bike at any point, but if you leave your bike somewhere you must return to the same location to pick it up before riding the bike again.  Additionally, you can't carry your bike on non-bike routes. What is the shortest amount of cumulative time it will take to travel to all the places you need to go and return you and the bike to your starting location?

Figure 1: This figure shows sample input 11, with bike paths in red/curved and non-bike paths in black/straight.

입력

The problem input describes a multigraph with two different types of edges: edges for bike paths and edges for non-bike paths.

The first line contains one integer nn, 0<n3000 < n \leq 300, the number of locations on campus.  The locations will be numbered from 00 to n1n-1. Location 00 is your home, which is the starting and ending location of you and your bike.

The second line contains one integer xx, 0<xn(n1)/20 < x \leq n(n-1)/2, the number of bike paths.

Each of the next xx lines contains a description of a bike path. Each line will have 33 integers uu vv tt, where 0u<n0 \leq u < n is the starting location of the path, 0v<n0 \leq v < n is the ending location of the path, and 0t1060 \leq t \leq 10^6 is the time it takes to travel from uu to vv and from vv to uu by bike.

The next line contains one integer yy, 0<yn(n1)/20 < y \leq n(n-1)/2, the number of non-bike paths.

Each of the next yy lines contains a description of a non-bike path. Each line will have 33 integers uu vv tt, where 0u<n0 \leq u < n is the index of the starting location of the path, 0v<n0 \leq v < n is the index of the ending location of the path, and t106t \leq 10^6 is the time it takes to travel from uu to vv and from vv to uu using a bike alternative.

All paths can be taken in either direction, and the amount of time it takes to travel on either direction of the same path is the same. There will be at most one bike path and at most one non-bike path between any two locations.  No path starts and ends at the same location.

The next line contains an integer zz, 0<z3000 < z \leq 300, indicating the number of locations you have to visit on your route.  The next line will contain zz integers 0a_1,a_2,...,a_z<n0 \leq a\_1, a\_2, ..., a\_z < n, the indices of the locations you must visit.  The locations must be visited in the order in which they are listed, but there are no restrictions on how often you may pass through any location on your trip.

출력

Output the minimum possible cumulative travel time, with you and the bike starting and ending at location 00. You are guaranteed that all locations on your route can be reached using some combination of bike and non-bike paths.