Under construction

Still being built. Things may change

Archipelago

Interview

Time limit2sMemory limit1024 MB

Summary
Given n island coordinates and a boat range d, rank each island by how many other islands are reachable through a chain of hops of length at most d.
Level

Medium4 of 10

Topics
Graph, Union-find, Geometry, Sorting
Solved
No attempts yet

Problem

The company you work for, Boats to Get Out (BGO), has recently discovered a new archipelago, and it is an ideal spot to develop into a tourist destination. The islands are all extremely tiny, so there should be ample opportunity to base almost all transportation in the region on boats.

Unfortunately, the islands are so far out in the ocean that the standardized boat BGO provides cannot reach any of them from the mainland; the boat can hold only enough fuel to travel a distance of dd kilometers. To access the archipelago at all, an airport must therefore be built on one of the islands. But where should it be located?

The BGO boss has ordered you to list all the islands in order from highest to lowest airport utility. The airport utility of an island is defined as the number of islands it is possible to reach by boat from that island, using any number of intermediate stops on other islands for refuelling.

Input

The first line of input consists of two space-separated integers 1≤n<2 0001 \leq n < 2\,000 and 1≤d<1061 \leq d < 10^6, where nn is the number of islands and dd is how far a boat can travel in kilometers before it needs to refuel. The islands are named from 11 to nn. The next nn lines of input describe the locations of the islands. The ithi^{\text{th}} such line contains two space-separated integers 0≤xi<1070 \leq x_i < 10^{7} and 0≤yi<1070 \leq y_i < 10^{7}, which describe the coordinates of island ii.

Output

Output a single line containing nn space-separated integers indicating a ranking of the islands from highest to lowest airport utility. If there are multiple islands with the same utility, you may output them in any order as long as their airport utility is non-increasing.

Examples2

  1. Example 1

    Input
    7 3
    1 1
    3 2
    2 3
    4 2
    12 5
    13 7
    11 6
    
    Expected output
    1 2 3 4 5 6 7
    
  2. Example 2

    Input
    3 4
    2 5
    5 0
    4 4
    
    Expected output
    1 3 2