# UVA 10034 - Freckles

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 5000;
int r[MAXN], u[MAXN], v[MAXN];
double w[MAXN], X[110], Y[110];
int p[110];
int n, m;
//两点间距离
double Distance(int x1, int y1, int x2, int y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
//间接排序，按边的长度将边的序号排序
int cmp(const int i, const int j)
{
return w[i] < w[j];
}
//并查集的Find函数
int Find(int x)
{
return p[x] == x ? x : p[x] = Find(p[x]);
}

double Kruskal()
{
double ans = 0;
for (int i = 0; i < n; i++) p[i] = i;       //初始化并查集
for (int i = 0; i < m; i++) r[i] = i;       //初始化边序号
sort(r, r + m, cmp);        //给边排序
for (int i = 0; i < m; i++)
{
int e = r[i];           //找出当前边两个端点所在集合编号
int x = Find(u[e]);
int y = Find(v[e]);
if (x != y)             //如果在不同集合，合并
{
ans += w[e];
p[x] = y;
}
}
return ans;
}

int main()
{
int t;
double x, y;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
m = 0;
for (int i = 0; i < n; i++)         //读入点，计算边
{
scanf("%lf%lf", &X[i], &Y[i]);
for (int j = 0; j < i; j++)
{
u[m] = i;
v[m] = j;
w[m++] = Distance(X[i], Y[i], X[j], Y[j]);
}
}

printf("%.2lf\n", Kruskal());
if (t)                  //两组数据间有一空行，否则WA，UVAoj目前没有PE
printf("\n");
}
return 0;
}