PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000357. Phủ điểm qua đường thẳng (Underwater Snipers)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phủ điểm qua đường thẳng (Underwater Snipers)

Underwater Snipers

Source: ICPC Live Archive

Version: Phuoc Hung OJ Extended

Problem Statement

The horizontal line y=ky=k divides the coordinate plane into two halves. There are NN points above it; point ii has coordinates (xi,yi)(x_i,y_i).

Place SS centers of circles of radius DD strictly below the line, so every center has a y-coordinate smaller than kk. Both the given points and the centers have integer coordinates. Once placed, the centers remain fixed. A point is covered when its Euclidean distance to at least one center is at most DD.

Let MM be the smallest distance from any center to the line y=ky=k. Find the maximum possible MM such that all given points are covered, or report that no placement exists.

Input

The first line contains four integers k,N,S,Dk,N,S,D: the line height, number of points, number of centers and radius. Each of the next NN lines gives two integers xi,yix_i,y_i, the coordinates of point ii.

Output

Print one integer, the maximum possible MM, or IMPOSSIBLE if no placement exists.

Subtasks

  • Subtask 1 (20 points): −30≤k<30-30\le k<30; 1≤N,S≤81\le N,S\le 8; 1≤D≤301\le D\le 30; −30≤xi≤30-30\le x_i\le 30, k<yi≤30k<y_i\le 30 for every 1≤i≤N1\le i\le N.
  • Subtask 2 (30 points): −106≤k<106-10^6\le k<10^6; 1≤N,S≤5001\le N,S\le 500; 1≤D≤1061\le D\le 10^6; −106≤xi≤106-10^6\le x_i\le 10^6, k<yi≤106k<y_i\le 10^6 for every 1≤i≤N1\le i\le N.
  • Subtask 3 (50 points): −108≤k<108-10^8\le k<10^8; 1≤N,S≤100001\le N,S\le 10000; 1≤D≤1091\le D\le 10^9; −108≤xi≤108-10^8\le x_i\le 10^8, k<yi≤108k<y_i\le 10^8 for every 1≤i≤N1\le i\le N.

Examples

Input 1

0 3 2 4
1 1
3 2
9 1

Output 1

2

Explanation 1

At height -2 the centers (3,-2) and (9,-2) cover all three points, with squared distances 13, 16 and 9 respectively. A depth of at least 3 would leave the point (3,2) at vertical distance at least 5, exceeding the radius 4. Thus 2 is optimal.

Input 2

0 3 1 4
1 1
3 2
9 1

Output 2

IMPOSSIBLE

Explanation 2

Only one center is allowed. The points (1,1) and (9,1) are eight units apart. A radius-four circle containing both must be centered at their midpoint (5,1), which lies above the line and is invalid.