/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming
Final Contest

Solution to Arctic Network: https://open.kattis.com/problems/arcticnetwork
*/

#include <bits/stdc++.h>
using namespace std;

//Compute the distance between two outposts
double dist(pair<int, int> a, pair<int, int> b) {
    return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

//A struct to represent edges between outposts
struct edge {
    int a, b;
    double d;
};

//DFS function to find connected components of outposts
void dfs(int u, vector<vector<int>> &adj, vector<bool> &seen) {
    seen[u] = true;
    for(int v : adj[u]) {
        if(seen[v]) continue;
        dfs(v, adj, seen);
    }
}

int main() {
    //Process test cases
    int t; cin >> t;
    while(t--) {
        int s, p;
        cin >> s >> p;
        vector<pair<int, int>> loc(p);
        for(int i = 0; i < p; i++) {
            cin >> loc[i].first >> loc[i].second;
        }

        //Store all edges between two outposts with their distances
        vector<edge> edges;
        for(int i = 0; i < p; i++) {
            for(int j = i+1; j < p; j++) {
                edges.push_back({i, j, dist(loc[i], loc[j])});
            }
        }

        //eps is a small value to check for equality using doubles
        const double eps = 1e-6;
        double lo = 0.0, hi = 1e8;

        //Binary search the answer
        while(lo < hi - eps) {
            double m = (lo + hi) / 2;

            //Create an adjacency list where only edges that have distance <= m are included
            vector<vector<int>> adj(p);
            for(edge e : edges) {
                if(e.d < m) {
                    adj[e.a].push_back(e.b);
                    adj[e.b].push_back(e.a);
                }
            }

            //Use DFS to determine how many distinct components there are
            vector<bool> seen(p, false);
            int c = 0;
            for(int i = 0; i < p; i++) {
                //If node i is not yet visited, start a new DFS from i
                if(!seen[i]) {
                    dfs(i, adj, seen);
                    c++;
                }
            }

            //We will need c satellites to connect all of the components, unless there is only one component,
            //in which case we do not require any satellites
            if(c == 1) c = 0;

            //If too many satellites are required, we must increase the distance
            if(c > s) lo = m + eps;
            //Otherwise, we can try a lower distance
            else hi = m;
        }

        //Display the answer to 2 decimal places
        cout << setprecision(2) << fixed << lo << endl;
    }
}