#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long 
#define FB(i,n) for (int i=0;i<n;i++) 
#define ull unsigned long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define input(a) for(int i=0;i<n;i++) cin>>a[i];
#define test int t; cin>>t; while(t--)
#define vi vector<int>
#define vll vector<pair<long long,long long>>
#define ii pair<int,int>
using namespace std;
bool comp(ll double a,ll double b) {
    return a>b;
}
void solve(){
	int n;
	cin>>n;
	vector<ll ll> mintt,minr;
	int q=2*n;
	while(q--) {
	    ll ll x,y;
	    cin>>x>>y;
	    if(!x) {
	        mintt.push_back(abs(y));
	    } else {
	        minr.push_back(abs(x));
	    }
	}
	sort(all(mintt));
	sort(all(minr));
	ll double ans=0;
	FB(i,n) {
	    ans=ans+sqrt(mintt[i]*mintt[i]+minr[i]*minr[i]);
	}
	cout<<setprecision(12)<<fixed<<ans<<endl;
}

int main(){
	IOS; 
	test {
		solve();
	}
return 0;
}

