Aqueduct Construction

Each town must connect to a distinct spring through downhill hops of limited length so the combined aqueduct length is minimal.

Medium7Shortest pathGraphDynamic programmingNo attempts yetTime limit3sMemory limit256 MB

Problem

After conquering Britannia, the Roman general Agricola decided that every one of his new towns should draw water from the natural springs of the province. His advisor Wessus Waterus was told to design the aqueducts.

Hills and valleys lie between the springs and the towns. An aqueduct is built from segments, and every segment starts on one hilltop and ends on another. Water flows downhill only, so a segment must run from a higher hill to a lower one. Two hills of equal height cannot be joined by a segment. A hill, a spring or a town standing under a segment is no problem, because the segment tunnels straight through it. Roman engineering has one limit: a single segment can be at most qq long.

The length of a segment is the three dimensional Euclidean distance between the two hilltops, (x1x2)2+(y1y2)2+(h1h2)2\sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(h_1-h_2)^2}. The length of an aqueduct from a spring to a town is the sum of the lengths of its segments.

Every town has to be fed by its own spring, and one spring cannot feed two towns. Aqueducts may cross each other. Make the total length of all the aqueducts as small as possible.

Input

One line with four integers nn, ss, tt and qq: the number of hills (0<n5000 < n \le 500), the number of springs (1s401 \le s \le 40), the number of towns (1ts1 \le t \le s) and the maximum length of one segment (1q3×1061 \le q \le 3 \times 10^6).

Then nn lines. The iith of them holds the space separated integers xix_i, yiy_i and hih_i, the coordinates and the height of a hill (0xi,yi,hi1060 \le |x_i|, |y_i|, h_i \le 10^6). The hills are numbered 1 to nn in the order given.

Then one line with ss space separated integers, the numbers of the hills that carry a spring.

Then one line with tt space separated integers, the numbers of the hills that carry a town.

A hill carries at most one spring or one town.

Output

Print one line with the smallest total aqueduct length that feeds every town from a spring of its own, rounded to exactly six digits after the decimal point. If no such supply exists, print IMPOSSIBLE instead.