Arctic Network

Time limit1sMemory limit128 MB

Summary
Given P outposts and S satellite channels, find the minimum radio range D so that all outposts stay connected, where satellite-linked outposts communicate freely.
Level

Medium7 of 10

Topics
Minimum spanning tree, Union-find, Graph, Greedy
Solved
No attempts yet

Problem

The Department of National Defence (DND) wants to connect several northern outposts with a wireless network. Two communication technologies are used to build the network: every outpost is equipped with a radio transceiver, and some outposts additionally have a satellite channel.

Any two outposts that both have a satellite channel can communicate through the satellite, no matter where they are located. Otherwise, two outposts can communicate by radio only if the distance between them is at most DD, which depends on the transmitter power. Higher power gives a larger DD but costs more. For purchasing and maintenance reasons the transceivers at all outposts must be identical; that is, the value of DD is the same for every pair of outposts.

Determine the minimum DD such that every pair of outposts is connected by at least one communication path, whether direct or indirect.

Input

The first line contains the number of test cases NN. For each test case, the first line contains the number of satellite channels SS and the number of outposts PP (1≤S≤1001 \le S \le 100, S<P≤500S < P \le 500). The next PP lines each contain the coordinates (x,y)(x, y) of an outpost in kilometres. Each coordinate is an integer between 00 and 10 00010\,000 inclusive.

Output

For each test case, output on a single line the minimum DD required to connect the network. Print the value to two decimal places.

Examples1

  1. Example 1

    Input
    1
    2 4
    0 100
    0 300
    0 600
    150 750
    
    Expected output
    212.13