Hide

Problem A
Archipelago

The company you work for, Boats to Get Out (BGO), has recently discovered a new archipelago that simply begs to become a new tourism hotspot. 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 provide is not able to reach any of them from the mainland; their boats can only hold enough fuel to travel a distance of $d$ kilometers. To access the archipelago at all hence require that an airport is built on one of the islands. But where should it be located?

The BGO boss has ordered you to list out 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 \leq n < 2\, 000 $ and $1 \leq d < 10^6$, where $n$ signify the number of islands and $d$ indicates how far a boat can travel in kilometers before it needs to refuel. The islands are named from $1$ to $n$. The next $n$ lines of input describes the location of the islands. The $i^{\text {th}}$ such line contains two space-separated integers $0 \leq x_ i < 10^{7}$ and $0 \leq y_ i < 10^{7}$ which describe the coordinates of island $i$.

Output

Output a single line containing $n$ 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.

Sample Input 1 Sample Output 1
7 3
1 1
3 2
2 3
4 2
12 5
13 7
11 6
1 2 3 4 5 6 7
Sample Input 2 Sample Output 2
3 4
2 5
5 0
4 4
1 3 2

Please log in to submit a solution to this problem

Log in