import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static int numDots;
static Node[] adjacencyList;
static class Node{
double key;
boolean visited;
int data;
double x;
double y;
ArrayList<Node> children;
Node parent;
public Node(double x, double y, int data){
this.data = data;
this.x = x;
this.y = y;
visited = false;
children = new ArrayList<Node>();
parent = null;
}
}
public static void main
(String[] args
) { Scanner sc
= new Scanner
(System.
in); int numCases = sc.nextInt();
sc.nextLine();
for(int g = 0; g<numCases; g++){
sc.nextLine();
numDots = sc.nextInt();
adjacencyList = new Node[numDots];
for(int a = 0; a<numDots; a++){
Node n = new Node(sc.nextDouble(), sc.nextDouble(), a);
adjacencyList[a] = n;
}
//add children to each node
for(int b = 0; b<numDots; b++){
for(int c = 0; c<numDots; c++){
if(b!=c)
adjacencyList[b].children.add(adjacencyList[c]);
}
}
adjacencyList[0].key = 0;
for(int a = 0; a<numDots; a++){
int u = getMinKey();
adjacencyList[u].visited = true;
for(int b = 0; b<numDots; b++){
double newKey = 0;
if(adjacencyList
[b
].
visited == false && (newKey
= Math.
sqrt(Math.
pow(Math.
abs(adjacencyList
[u
].
x-adjacencyList
[b
].
x),
2.0) + Math.
pow(Math.
abs(adjacencyList
[u
].
y - adjacencyList
[b
].
y),
2.0))) < adjacencyList
[b
].
key){ adjacencyList[b].key = newKey;
adjacencyList[b].parent = adjacencyList[u];
}
}
}
double sum = 0;
for(int z = 0; z<numDots; z++){
sum+=adjacencyList[z].key;
}
System.
out.
printf("%.2f",sum
); if(g<numCases-2)
}
}
public static int getMinKey(){
int minIndex = 0;
double minKey
= Double.
MAX_VALUE; for(int a = 0; a<numDots; a++){
if(adjacencyList[a].visited == false && adjacencyList[a].key < minKey){
minKey = adjacencyList[a].key;
minIndex = a;
}
}
return minIndex;
}
}