#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
int T,n,x,y;
int main()
{
	cin>>T;
    while (T--)
    {
        cin>>n;
        vector<int>xa,ya;
        for (int i=1;i<=n+n;i++)
        {
            cin>>x>>y;
            if (x==0) ya.push_back(abs(y));
            else xa.push_back(abs(x));
        }
        sort(xa.begin(),xa.end());
        sort(ya.begin(),ya.end());
        double ans=0;
        for (int i=0;i<n;i++)
        {
            double x=xa[i],y=ya[i];
            ans+=sqrt(x*x+y*y);
        }
        printf("%.15lf\n",ans);
    }
    return 0;
}
 