Finding a House

On a weighted undirected graph, find the vertex with no McDonald's or Starbucks whose distance to the nearest McDonald's is at most x, to the nearest Starbucks at most y, and whose two distances sum to the minimum.

Medium6GraphShortest pathDynamic programmingNo attempts yetTime limit1sMemory limit256 MB

Problem

Sanghyuk lives in Anyang and is worn out after four years of commuting, so he wants to find a house in Seoul. The house he wants meets all three conditions below.

  • Near a McDonald's: the shortest distance from the house to the nearest McDonald's is at most xx.
  • Near a Starbucks: the shortest distance from the house to the nearest Starbucks is at most yy.
  • Among the houses that meet both conditions above, the sum of the two shortest distances is the smallest.

The commute has worn Sanghyuk down and he cannot decide on a house. Solve the problem for him. A map of the area he is moving to is given as a weighted graph, and the McDonald's and Starbucks locations are given as vertex numbers. Write a program that prints the sum of the two shortest distances for the house Sanghyuk wants. Every vertex that has neither a McDonald's nor a Starbucks has a house.

In the map above, a square is a vertex with a McDonald's, a star is a vertex with a Starbucks, and each circle is a vertex with a house. When xx is 6 and yy is 4, the house that answers the question is vertex 6. Its shortest distance to a McDonald's is 2 and its shortest distance to a Starbucks is 4, so the sum is 6. Vertex 7 also meets both conditions, but its two shortest distances are 6 and 2 for a sum of 8, which is larger than the value at vertex 6, so it is not the answer. Vertices 2, 3 and 4 fail to meet both conditions at once, so none of them can be the answer.

Input

The first line has the number of vertices V(3V10000)V(3 \le V \le 10000) and the number of roads E(0E300000)E(0 \le E \le 300000). Each of the next EE lines has three integers uu, vv and ww in that order. They mean there is a road of weight w(1w<10000)w(1 \le w < 10000) between vertices uu and v(1u,vV)v(1 \le u, v \le V). uu and vv are different, and several roads may join the same pair of vertices.

The next line has the number of McDonald's locations M(1MV2)M(1 \le M \le V-2) and the threshold x(1x100000000)x(1 \le x \le 100000000), and the line after it has the MM vertex numbers that have a McDonald's. The next line has the number of Starbucks locations S(1SV2)S(1 \le S \le V-2) and the threshold y(1y100000000)y(1 \le y \le 100000000), and the line after it has the SS vertex numbers that have a Starbucks.

  • A vertex with a McDonald's or a Starbucks has no house.
  • One vertex may have both a McDonald's and a Starbucks.
  • At least one vertex has a house.

Output

Print the sum of the shortest distance to a McDonald's and the shortest distance to a Starbucks for the house Sanghyuk wants. If no house meets the conditions, print -1.