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

#GD0000084. Lắp đặt ra-đa (Radar Installation)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Lắp đặt ra-đa (Radar Installation)

Radar Installation

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

The coastline is the xx-axis. Islands lie at points (xi,yi)(x_i,y_i) with yi≥0y_i\ge0. Radar stations may be placed anywhere on the coastline and each covers islands within Euclidean distance dd. Find the minimum number of stations needed to cover all islands, or -1 if any island is unreachable.

Input

The first line contains n,dn,d. Each of the next nn lines contains xi,yix_i,y_i.

Output

Print the minimum number of radars, or -1 if any island cannot be covered.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤d≤1041\le d\le10^4; −104≤xi≤104-10^4\le x_i\le10^4; 0≤yi≤1040\le y_i\le10^4.
  • Subtask 2 (30 points): 1≤n≤3001\le n\le 300; 1≤d≤1041\le d\le10^4; −104≤xi≤104-10^4\le x_i\le10^4; 0≤yi≤1040\le y_i\le10^4.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000; 1≤d≤1041\le d\le10^4; −104≤xi≤104-10^4\le x_i\le10^4; 0≤yi≤1040\le y_i\le10^4.

Examples

Input

3 2
1 2
-3 1
2 1

Output

2

Explanation

The island (1,2)(1,2) can only be covered from coastal coordinate x=1x=1. From there, (2,1)(2,1) is also within radius 22. The leftmost island (−3,1)(-3,1) requires another radar, so two radars are necessary.