#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int t,n;
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n); double ans=0;
        vector<double>miners; vector<double>diamonds;
        for(int i=0;i<2*n;i++){
           double a,b;
            scanf("%lf%lf",&a,&b);
            if (a==0){miners.push_back(abs(b));}
            if (b==0){diamonds.push_back(abs(a));}
        }
        sort(miners.begin(),miners.end());
        sort(diamonds.begin(),diamonds.end());
        for (int i=0;i<n;i++){
            ans+=sqrt(miners[i]*miners[i]+diamonds[i]*diamonds[i]);
        }
        printf("%.15lf\n",ans);
    }
    return 0;
}