// Arup Guha
// 6/18/2026
// Solution to Kattis Problem: Arctic Network
// https://open.kattis.com/problems/arcticnetwork

using namespace std;
#include <bits/stdc++.h>

int n, maxComp;
vector<pair<int,int>> pts;

int getNumComp(double r);
void dfs(int v, vector<bool>& reach, double r);
double dist(int i, int j);

int main() {

    // Process cases.
    int nC;
    cin >> nC;
    for (int loop=0; loop<nC; loop++) {

        // Read in points.
        cin >> maxComp >> n;
        pts.clear();
        for (int i=0; i<n; i++) {
            int x, y;
            cin >> x >> y;
            pts.push_back(pair<int,int>{x,y});
        }

        // Run binary search on answer.
        double low = 0, high = 100000;
        for (int i=0; i<100; i++) {

            double mid = (low+high)/2;

            // See how many networks you need with a radius of mid.
            int numComp = getNumComp(mid);

            // Answer is no more than mid.
            if (numComp <= maxComp)
                high = mid;

            // Answer is at least mid.
            else
                low = mid;
        }

        // Ta da!
        printf("%.2lf\n", low);
    }

    return 0;
}

int getNumComp(double r) {

    // Marks connected locations.
    vector<bool> reach(n, false);

    // Numver of components.
    int res = 0;

    // Go through each location.
    for (int i=0; i<n; i++) {

        // Connected already.
        if (reach[i]) continue;
        res++;

        // Form new component.
        dfs(i, reach, r);
    }

    // # of components.
    return res;
}

void dfs(int v, vector<bool>& reach, double r) {

    // Mark it.
    reach[v] = true;

    // Try each neighbor.
    for (int i=0; i<n; i++) {

        // Been here.
        if (reach[i]) continue;

        // Too far.

        if (dist(v, i) > r) continue;

        // Recurse...
        dfs(i, reach, r);
    }
}

// Returns the distance between points i and j.
double dist(int i, int j) {
    return sqrt( (pts[i].first-pts[j].first)*(pts[i].first-pts[j].first) +
                 (pts[i].second-pts[j].second)*(pts[i].second-pts[j].second) );
}
