eolymp
bolt
Try our new interface for solving problems
Problems

The Glorious Karlutka River =)

The Glorious Karlutka River =)

Time limit 0.5 seconds
Memory limit 256 MiB

A group of M tourists are walking along the Karlutka river. They want to cross the river, but they couldn't find a bridge. Fortunately, there are some piles of rubbish floating in the water, and the tourists have decided to try to cross the river by jumping from one pile to another.

A tourist can move up to D meters in any direction at one jump. One jump takes exactly one second. tourists know that the river is W meters wide, and they have estimated the coordinates of rubbish piles (X_i, Y_i) and the capacity of each pile (C_i, the maximum number of tourists that this pile can hold at the same time). Rubbish piles are not very large and can be represented as points. The river flows along the X axis. tourists start on the river bank at 0 by Y axis. The Y coordinate of the opposite bank is W.

tourists would like to know if they can get to the opposite bank of the river, and how long it will take.

Input data

First line of input consists of four integers: number of rubbish piles N (0N50), number of tourists M (0 < M50), maximum length of tourist's jump D (0D1000), and width of the river W (0 < W1000). Following N lines describe the rubbish piles, each line consists of three integers: (0 < X_i < 1000, 0 < Y_i < W, 0C_i1000) — pile coordinates and capacity.

Output data

Output a single number indicating the minimal time (in seconds) in which all tourists will be able to cross the river, or the line "IMPOSSIBLE" if it is impossible to cross the river.

Examples

Input example #1
3 10 3 7
0 2 2
4 2 2
2 4 3
Output example #1
6
Source Izhevsk STU Contest, Petrozavodsk training camp, February 6, 2009