//Do post the solution if anyone is able to solve it
There is an infinite grid. You are given N points on it. 2 points are said to be connected if the manhattan distance between them is equal to 1. If two points are not connected you can connect by air-pathways i.e. you can take a flight from one point to the other. The cost of an airpathway is the euclidean distance between the 2 points.
If there are three points A, B and C, Let's say points A & B are connected (by land or by air), B & C are connected (by land or by air) then by transitivity A & C are also connected. You have to connect all points in the same time minimizing the cost.
Input format
First line T, the no. of test cases
First line of each test case contains N
Then N lines follow where ith line contains the x and y coordinates of the ith point
Output format
For each test case output in a single line the minimum cost with 6 decimal places
Constraints
1<=T<=10
1<=N<=500
1<=x<=10^6
1<=y<=10^6
Sample test case
Input
1
3
1 1
2 2
3 2
output
1.414214