#include <stdio.h>
#include <math.h>

/* Global variables */
int coord[12][2] = {0};             /* x and y tree coordinates */
float output[25] = {0};             /* min dist for all test cases */
float min_dist = 0;                 /* min dist for each test case */
unsigned int combo[12] = {0};       /* max trees (2n where (n ≤ 6 ))*/
unsigned int n;                     /* possible ladders */

/* function declarations */
void get_dist(void);
void get_pairs(void);

/**
 * main - start of program
 * 
 * Return: 0 on success
 */
int main(void)
{
    int c;                          /* test cases (c ≤ 25) */
    int out = 0;                    /* iterator */

    scanf("%d", &c);                /* read test cases */
    while(c--)
    {
        min_dist = 1e9;
        int i = 1;
    
        scanf("%d",&n);             /* read value of n (n ≤ 6) */
        while (i <= 2 * n)
        {
            scanf("%d%d", &coord[i][0], &coord[i][1]);
            i++;
        }

        get_pairs();                    /* pair the trees */
        output[out] = min_dist;
        out++;
    }

    while (out--)                       /* print to stdout */
        printf("%0.3f\n", output[out]); 

    return (0);
}


/**
 * get_pairs - generates all possible tree pairs
 * 
 * Return: void
 */

void get_pairs(void)
{
    int x = 1;
   
    while (x <= 2 * n)
    { 
        if(!combo[x])
            break;
        x++;
    }
       
    if(x > 2 * n)
    {
        get_dist();
        return;
    }       
         
    for(int y = 1; y <= 2 * n; y++)
    {
            if(y != x && combo[y] == 0)
            {
                    combo[x] = y;
                    combo[y] = x;

                    get_pairs();    /* use recursion for pairing */

                    combo[x] = 0;
                    combo[y] = 0;
            }
    }       
}


/**
 * get_dist - computes the min possible distance btwn pairs and
 * updates the min_dist variable
 * 
 * Return: void 
 */
void get_dist(void)
{
    float dist = 0;
    for (int i = 1; i <= 2 * n; i++)
    {
        dist += sqrt((coord[i][0] - coord[combo[i]][0])
                    *(coord[i][0] - coord[combo[i]][0])
                    +(coord[i][1] - coord[combo[i]][1])
                    *(coord[i][1] - coord[combo[i]][1]));
    }
    dist /= (float)2;     
    
    min_dist = min_dist > dist ? dist : min_dist; 
}