Hot Sand and Umbrellas

Find the minimum total time Kevin sprints on hot sand to go from the car to the ball and back, cooling at circular umbrellas, where each sun run is at most k seconds and the ball visit does not reset the limit.

Hard8GraphShortest pathGeometryMathNo attempts yetTime limit2sMemory limit512 MB

Problem

Kevin got back to his car after a morning at the beach and was about to drive away when he realised he had left his ball behind. He remembers exactly where it is. The trouble is the heat: sand in direct sunlight is scorching, and Kevin can run on hot sand for at most kk seconds at a time. On hot sand he runs at exactly 1 metre per second.

Umbrellas are scattered around the beach. Each umbrella is a perfect circle, and the sand under it stays cool. Every time Kevin reaches an umbrella, he waits there until his feet have cooled down enough to run for another kk seconds. He can cool his feet at the car too, so he starts out with cool feet. Time spent in the shade or at the car does not count as time in the sun, and neither does moving around inside the shade.

Kevin never runs more than kk seconds on hot sand at a time, so if two umbrellas are more than kk metres apart he will not run between them. Picking up the ball does not cool his feet. The run from the last cool spot to the ball and the run from the ball to the next cool spot count together against the same kk seconds.

Determine the minimum time Kevin must spend in the sun to retrieve his ball and return to the car.

Input

The first line contains four integers nn, kk, xx and yy. Here nn (0n1000 \le n \le 100) is the number of umbrellas, kk (1k1001 \le k \le 100) is how far Kevin can run on hot sand at a time, in metres, and (xx, yy) (100x100-100 \le x \le 100, 100y100-100 \le y \le 100) is the position of the ball. Kevin starts at his car at (0, 0). Treat Kevin and the ball as single points.

Each of the next nn lines describes one umbrella with three integers xx, yy and rr (100x100-100 \le x \le 100, 100y100-100 \le y \le 100, 1r1001 \le r \le 100). The umbrella is the circle centred at (xx, yy) with radius rr.

Several things (the ball, one or more umbrellas, Kevin) may sit at the same place. All lengths are in metres.

Output

Print the minimum time in seconds that Kevin must spend in the sun, rounded to 10 digits after the decimal point. If he cannot retrieve the ball and return to the car, print -1 instead.