#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
int main(){
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    int T; cin>>T;
    while(T--){
    	int n; cin>>n;
    	vector<int> a,b;
    	for(int i=0;i<2*n;i++){
    		int x,y; cin>>x>>y;
    		if(x==0) a.push_back(abs(y));
    		else b.push_back(abs(x));
    	}
    	sort(a.begin(),a.end());
    	sort(b.begin(),b.end());
    	double ans = 0;
    	for(int i=0;i<n;i++){
    		ans += sqrt(1ll*a[i]*a[i]+1ll*b[i]*b[i]);
    	}
    	cout<<ans<<endl;
    }
}
