#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
 
#define f(i,a,b) for(ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for(ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll  i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll) a.size()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller   ios::sync_with_stdio(false);cin.tie(0)
 
// policy-based
 
 
 
 
using namespace std;
 
typedef long long ll; // ll or ll
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 3e5 + 20;
const ll mod = 1e9 + 7;
const ll inf = 2e9;



int main(){ 
	fastio;
	ll tc,n,u,v;
	cout << fixed << setprecision(12) ;
	cin >> tc;
	while(tc--){
		cin >> n;
		vi x,y;
		f(i,0,2*n){
			cin >> u >> v;
			if(u == 0) y.push_back(abs(v));
			else x.push_back(abs(u)); 
		}
		sort(all(x)) , sort(all(y));
		ld ans = 0;
		f(i,0,n) ans += sqrt(x[i]*x[i] + y[i]*y[i]);
		cout << ans << endl;
	}
	return 0;
}
